%option noinput nounput noyywrap 8bit nodefault %option reentrant bison-bridge bison-locations %option prefix="kalmia" %start STRING %{ #include #define YYLTYPE KALMIALTYPE #define YYSTYPE KALMIASTYPE #include "kalmia.tab.h" #define YY_USER_ACTION \ yylloc->first_line = yylloc->last_line; \ yylloc->first_column = yylloc->last_column; \ if (*yytext == '\n') { \ yylloc->last_line += 1; \ yylloc->last_column = 0; \ } \ else { \ yylloc->last_column += yyleng; \ } %} S \x20\x0a\x0d\x09 DATE [0-9]{4}\-[0-9]{2}\-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}[A-Z]* ATTR ([\x20\x0a\x0d\x09]*)?"=" %% "" { /* xml prologue */ return PROLOG; } [\x20\x0a\x0d\x09] { /* ignore whitespace */ } "<" { return S_TAG_OPEN; } "">" { return TAG_CLOSE; } "/>" { return EMPTY_TAG_CLOSE; } "float_array" { /* float_array tag */ return FLOAT_ARRAY; } "param" { /* param tag */ return PARAM; } "id"/{ATTR} { /* id attribute */ return ID_ATTR; } "count"/{ATTR} { /* count attribute */ return COUNT_ATTR; } "name"/{ATTR} { /* name attribute */ return NAME_ATTR; } "type"/{ATTR} { /* type attribute */ return TYPE_ATTR; } [a-zA-Z_:][a-zA-Z0-9\.\-_:]* { /* generic tag name */ yylval->sval = strdup(yytext); return NAME; } [a-zA-Z_:][a-zA-Z0-9\.\-_:]*/{ATTR} { /* generic attribute key */ yylval->sval = strdup(yytext); return ATTR; } "=" { /* attribute "=" */ return *yytext; } "\"" { /* begin a string */ BEGIN(STRING); return *yytext; } "\"" { /* end a string */ BEGIN(INITIAL); return *yytext; } [^"]+ { /* within a string */ yylval->sval = strdup(yytext); return TEXT; } -?[0-9]+ { /* integers */ yylval->lval = strtol(yytext, NULL, 10); return INTEGER; } -?[0-9]+\.?[0-9]* { /* doubles */ yylval->dval = strtod(yytext, NULL); return DOUBLE; } {DATE} { /* dates */ return DATE; }