%{
#include 
#include "meme.h"
#include "y.tab.h"
void yyerror(char *);
%}

%%

('[^'\n]*['\n])|(\"[^\"\n]*[\"\n])	 		{
					yylval.tValue = storeString(yytext+1);
					if(yylval.tValue[yyleng-2] != *yytext )
						warning("Unterminated character string",(char *)0);
					else
						yylval.tValue[yyleng-2] = 0; // remove closing quote
					return STRING;
				}
\/\/[^\n]*\n		; // ignore comments

">="            return GE;
"<="            return LE;
"=="            return EQ;
"!="            return NE;
"and" 			return AND;
"or" 			return OR;
"not" 			return NOT;
"while"         return WHILE;
"do"			return DO;
"until" 		return UNTIL;
"if"            return IF;
"else"          return ELSE;
"for" 			return FOR;
"in" 			return IN;
"print"         return PRINT;
"null" 			return NULLVAL;
"false" 		return FALSEVAL;
"true" 			return TRUEVAL;
"define" 		return DEFINE;
"return" 		return RETURN;
"break" 		return BREAK;
"method" 		return METHOD;

[a-zA-Z]([a-zA-Z0-9]|_)*       { 
                yylval.sName = storeString( yytext );
                return VARIABLE;
            }

[0-9]+      {
                yylval.iValue = atoi(yytext);
                return INTEGER;
            }

[0-9]+"."[0-9]* |
"."[0-9]+	{
				yylval.rValue = atof(yytext);
				return REAL;
			}
			
[-()\[\]<>=+%*/{}.,] {
                return *yytext;
             }
#.*\n		{ countLine(); return EOL; } /* ignore comments */

[\n] 		{ countLine(); return EOL; }
[;]			return EOL;

[ \t]+        ;       /* ignore whitespace */

.               yyerror("Unknown character");
%%
int yywrap(void) {
    return 1;
}