%{ #include #include #include "modsynnode.h" #include "modgram.h" void mod_error(const char *); void yyerror2( const string &, const string & ); %} DIGIT [0-9] NONDIGIT [_a-zA-Z] S-ESCAPE \|\"|\?|\\|\a|\b|\f|\n|\r|\t|\v S-CHAR [^"\\]* Q-CHAR [^'\\]* Q-IDENT \'({Q-CHAR}|{S-ESCAPE})({Q-CHAR}|{S-ESCAPE})*\' STRING \"({S-CHAR}|{S-ESCAPE})*\" ID {NONDIGIT}({DIGIT}|{NONDIGIT})*|{Q-IDENT} UNSIGNED_INTEGER {DIGIT}+ UNSIGNED_NUMBER {UNSIGNED_INTEGER}(\.{UNSIGNED_INTEGER}?)?([eE][+-]?{UNSIGNED_INTEGER})? %% "model" return MODEL; "import" return IMPORT; "connect" return CONNECT; "equation" return EQUATION; "end" return END; "start" return START; {ID} { mod_lval.id = new string( mod_text ); return IDENT; } {UNSIGNED_INTEGER} { mod_lval.val = atof(mod_text); return NUM; } {UNSIGNED_NUMBER} { mod_lval.val = atof(mod_text); return NUM; } [-()<>=+*/;,{}.] { return *mod_text; } [ \t\n]+ ; /* ignore whitespace */ . { yyerror2( "Unrecognized character: ", mod_text ); } %% int mod_wrap(void) { return 1; } void yyerror2( const string &msg1, const string &msg2 ) { const char *s = (msg1 + msg2).data(); mod_error( s ); }