-
kdevelop
Hi!
I'm trying to simulate a sort of terminal simulation ( or command prompt in D.O.S ), so that it reads commands from the keyboard. Using flex/bison (or lex/yacc) it should recognize commands and run a routine that I coded on another file.
I'm a complete newbie to linux c programming. I've tried flex/bison and gcc from the terminal and I've been able to run simple analyzers but I'm not sure how to even start with kdevelop, and how to compile everything. Excuse my stupidity but I'm new to the linux world (and so far I like it :) ).
I would appreciate a little help just to get started.
Thanks!
:)
-
I'm not asking how to use kdevelop I'm asking how to combine lex and yacc with c files to make a command interpreter in kdevelop :)
-
Following a tutorial on the web got this two files, I compiled them with:
flex ejemplo2.l
bison -d ejemplo2.y
gcc lex.yy.c ejemplo2.tab.c -o ejemplo2
../ejemplo2
This is the source:
*********** lexfile ****************
%{
#include <stdio.h>
#include "ejemplo2.tab.h"
%}
%%
\n return NL;
bye|quit|exit return BYE;
[0-9]+ return NUMBER;
heat return TOKHEAT;
on|off return STATE;
target return TOKTARGET;
temperature return TOKTEMPERATURE;
[ \t]+ ; /* Ignora los espacios en blanco */
..; /* Reconoce cualquier otra cosa y la ignora */
%%
*********** yaccfile ***************
%{
#include <stdio.h>
#include <string.h>
void yyerror (char *s);
%}
%token NUMBER TOKHEAT STATE TOKTARGET TOKTEMPERATURE NL BYE
%%
entrada: statement
| entrada statement
;
statement: NL
| exp NL
| BYE NL { printf("Cerrando calculadora...\n");exit(0); }
;
exp: TOKHEAT STATE { printf("\tHeat turned on or off\n"); }
|
TOKTARGET TOKTEMPERATURE NUMBER { printf("\tTemperature set to", $3); }
;
%%
void yyerror (char *s)
{
fprintf (stderr, "%s\n", s);
}
int yywrap()
{
return 1;
}
main()
{
yyparse();
}
*************************************
And finally my question would be how to put everything on a project plus some more code on another file that my commands (not these commands) would run after reading them.
So my question is more a Lex Yacc question on Kdevelop.
Hope that makes it clear,
Thanks in advance
:)
-
Habla espanol? No se nada de esto, pero, quiero decirle "Hola"