Hello all, I am a student of computer science, and I am currently writing an implementation of CRobots with Yacc and Lex.
Currently, the program works like this : - Tokens are defined in the .lex file - The grammar is defined in the .yacc file - The main function is defined in a .c file, which in turn, calls the yyparse function, with a few arguments. What I would like, is to be able to call the yyparse function, give it a string, which it will parse, and execute a function if the parsing is successfull. As an example : line : digit command eol {;} ; command : wait expression {yywait(&* bob_the_bot, $2); * next_line += 1;} | poke expression expression {yypoke(&* bob_the_bot,$2,$3); * next_line += 1;} All of the tokens are well defined, and when I compile with yacc -d grammar_burp.yacc && flex burp.flex && gcc lex.yy.c y.tab.c gameEngine.c -o burp , the compilation has no errors, but when I run the ./burp, I get a prompt where I can type text, instead of just executing the char passed to it. I would like something like this to work ; char * line = "0 WAIT (1+1)\n"; if(yyparse(line, rob, arn, next_line) == 0){ printf("Parsing completed !\n l : %i\n nl : %i", line, next_line); } else { perror("Parsing failed"); } In this example, it would parse the char * line, find the wait expression, validate it, and if successful, call the yywait() function. If need be, I can provide the full source code of the project. Thank you for your time.