%{ ////////////////////////////////////////////////////////////////////////////// // This file is part of Teyjus. // // // // Teyjus is free software: you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation, either version 3 of the License, or // // (at your option) any later version. // // // // Teyjus is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with Teyjus. If not, see . // ////////////////////////////////////////////////////////////////////////////// #include "../util/util.h" #include "op.h" #include "types.h" #include "y.tab.h" #include #include static int commentLev = 0; %} LETTER [A-Za-z] DIGIT [0-9] SYMBOL "_"|"+"|"-"|"*"|"/"|"!"|"~"|"@"|"$"|"%"|"^"|"&"|"*"|"<"|">"|"="|"'"|";"|":"|"," ID ({LETTER}|{SYMBOL})({LETTER}|{DIGIT}|{SYMBOL})* NUM {DIGIT}+ WSPACE [ \t]+ STRING [^*/]+ %x COMMENT C_COMMENT /* Some versions of lex require an explicit positions argument */ %p 10000 %% "\n" {continue; } "KIND" {return KIND; } "CONST" {return CONST; } "TYPE SKEL" {return TYSKEL; } "TYPE" {return TYPE; } "->" {return TYARROW; } "@" {return TYAPP; } "[" {return LBRACKET; } "]" {return RBRACKET; } "(" {return LPAREN; } ")" {return RPAREN; } "t," {return COMMA; } "#" {return POUND; } ";;" {return SEMICOLON; } "INFIX" {return INFIX; } "INFIXL" {return INFIXL; } "INFIXR" {return INFIXR; } "PREFIX" {return PREFIX; } "PREFIXR" {return PREFIXR; } "POSTFIX" {return POSTFIX; } "POSTFIXL" {return POSTFIXL; } "NOFIXITY" {return NOFIXITY; } "MIN1" {return MIN1; } "MIN2" {return MIN2; } "MAX" {return MAX; } "NOCODE" {return NOCODE; } "LOGIC SYMBOL" {return LSSYMB; } "LS_START" {return LSSTART; } "LS_END" {return LSEND; } "PRED SYMBOL" {return PREDSYMB; } "PRED_START" {return PREDSTART; } "PRED_END" {return PREDEND; } "REGCL" {return REGCL; } "BACKTRACK" {return BACKTRACK; } "TRUE" {return TRUE; } "FALSE" {return FALSE; } {WSPACE} {continue; } "/%" {commentLev = 1; BEGIN(COMMENT); continue; } "/*" {BEGIN(C_COMMENT); continue; } {ID} {yylval.name = strdup(yytext); return ID; } {NUM} {yylval.isval.ival = atoi(yytext); yylval.isval.sval = strdup(yytext); return NUM; } "*/" {BEGIN(INITIAL); continue; } {STRING} {yylval.text = strdup(yytext); return STRING; } [^%/\n]+ {continue; } "/%" {commentLev++; continue; } "%/" {commentLev--; if (!commentLev) BEGIN(INITIAL); continue; } . {return ERROR; }