2004-01-30 15:21:42 +00:00
|
|
|
%option reentrant bison-bridge bison-locations
|
|
|
|
%option noyywrap
|
|
|
|
%option never-interactive
|
|
|
|
|
|
|
|
|
|
|
|
%{
|
|
|
|
#include <string.h>
|
|
|
|
#include <aterm2.h>
|
|
|
|
#include "parser-tab.h"
|
|
|
|
|
|
|
|
static void initLoc(YYLTYPE * loc)
|
|
|
|
{
|
|
|
|
loc->first_line = 1;
|
|
|
|
loc->first_column = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void adjustLoc(YYLTYPE * loc, const char * s, size_t len)
|
|
|
|
{
|
|
|
|
while (len--) {
|
|
|
|
switch (*s++) {
|
|
|
|
case '\n':
|
|
|
|
++loc->first_line;
|
|
|
|
loc->first_column = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
++loc->first_column;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define YY_USER_INIT initLoc(yylloc)
|
|
|
|
#define YY_USER_ACTION adjustLoc(yylloc, yytext, yyleng);
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
|
|
ID [a-zA-Z\_][a-zA-Z0-9\_\']*
|
|
|
|
INT [0-9]+
|
|
|
|
STR \"[^\n\"]*\"
|
|
|
|
PATH [a-zA-Z0-9\.\_\-\+]*(\/[a-zA-Z0-9\.\_\-\+]+)+
|
2004-03-28 20:34:22 +00:00
|
|
|
URI [a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*\']+
|
2004-01-30 15:21:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
|
|
if { return IF; }
|
|
|
|
then { return THEN; }
|
|
|
|
else { return ELSE; }
|
|
|
|
assert { return ASSERT; }
|
|
|
|
let { return LET; }
|
|
|
|
rec { return REC; }
|
2004-02-02 21:39:33 +00:00
|
|
|
inherit { return INHERIT; }
|
2004-01-30 15:21:42 +00:00
|
|
|
|
|
|
|
\=\= { return EQ; }
|
|
|
|
\!\= { return NEQ; }
|
|
|
|
\&\& { return AND; }
|
|
|
|
\|\| { return OR; }
|
|
|
|
\-\> { return IMPL; }
|
2004-02-04 16:49:51 +00:00
|
|
|
\/\/ { return UPDATE; }
|
2004-01-30 15:21:42 +00:00
|
|
|
|
|
|
|
{ID} { yylval->t = ATmake("<str>", yytext); return ID; /* !!! alloc */ }
|
2004-01-30 17:06:03 +00:00
|
|
|
{INT} { int n = atoi(yytext); /* !!! overflow */
|
|
|
|
yylval->t = ATmake("<int>", n);
|
|
|
|
return INT;
|
|
|
|
}
|
2004-01-30 15:21:42 +00:00
|
|
|
{STR} { int len = strlen(yytext);
|
|
|
|
yytext[len - 1] = 0;
|
|
|
|
yylval->t = ATmake("<str>", yytext + 1);
|
|
|
|
yytext[len - 1] = '\"';
|
|
|
|
return STR; /* !!! alloc */
|
|
|
|
}
|
|
|
|
{PATH} { yylval->t = ATmake("<str>", yytext); return PATH; /* !!! alloc */ }
|
|
|
|
{URI} { yylval->t = ATmake("<str>", yytext); return URI; /* !!! alloc */ }
|
|
|
|
|
|
|
|
[ \t\n]+ /* eat up whitespace */
|
|
|
|
\#[^\n]* /* single-line comments */
|
|
|
|
\/\*(.|\n)*\*\/ /* long comments */
|
|
|
|
|
|
|
|
. return yytext[0];
|
|
|
|
|
|
|
|
|
|
|
|
%%
|