copyright (c) 2009 karim hamidou.
This is a rough translator for a subset of mojo to C.
-
+ It does no verifications whatsoever, everything is kept at the sole discretion
+ of the programmer.
+
*/
#include <stdio.h>
int r;
while((r = yylex()) != T_EOF) {
switch(r) {
+ case EOF:
+ break;
+
case SYMBOL:
symbol();
break;
int r = yylex();
switch(r) {
+ case EOF:
+ break;
+
case AFFECTATION:
- printf("struct Object *%s = ", symname);
+ yylex();
+ printf("struct Object *%s = %s;", symname, yytext);
break;
default:
while ((r = yylex()) && i < 4) {
switch(r) {
+ case EOF:
+ goto loop_exit;
+ break;
+
case COMMA:
break;
i++;
}
+ loop_exit:
if (i < 4) {
while(i < 3) {
printf("NULL,");
%}
%option yylineno
+%s raw
%%
:= { return AFFECTATION; }
\"[:alnum:]+\" { return STRING; }
[a-zA-Z][a-zA-Z0-9]* { return SYMBOL; }
-<<EOF>> { exit(0);}
+<<EOF>> { return; }
+\%\{ { BEGIN(raw); }
+<raw>\%\} { BEGIN(INITIAL); }
+<raw>.+ { printf("%s", yytext); }