I am trying to parse the following string input using Lex and Yacc with no success.
"@user;some random text; @another user; some other random text"
I am using the following grammar:
/* Lambda calculus grammar by Zach Carter */
%lex
%%
\s*\n\s* {/* ignore */}
";" { return 'SEP'; }
"@" { return 'AT'; }
[a-zA-Z]+ { return 'VAR'; }
<<EOF>> { return 'EOF'; }
/lex
%%
file
: expr EOF
{ return $expr; }
| EOF
;
expr
: AT expression
| expression
| SEP expression
;
expression
: VAR
{ $$ = yytext; }
;
You can give this grammar a try here:
The result I i would like to have is:
"@user;some random text; @another user; some other random text"
Output:
user some
random text
another user
some other random text