/*
* This file is part of Unicorn Sparkle Basic and is released under
* CC0 1.0 Universal License. See LICENSE.txt file or
* https://creativecommons.org/publicdomain/zero/1.0/ for full license
* text.
*/
%{
#include <gc.h>
#include "usbasic.tab.h"
#define yyalloc(sz) GC_malloc(sz)
#define yyfree(ptr) GC_free(ptr)
#define yyrealloc(ptr, sz) GC_realloc(ptr, sz)
%}
%option nounput noinput
%%
[ \t]+ ; /* Ignore whitespaces */
\n { return 0; }
"run" return RUN;
"print" return PRINT;
"if" return IF;
"then" return THEN;
"goto" return GOTO;
"<" return LT;
"<=" return LTE;
">" return GT;
">=" return GTE;
"==" return EQ;
-?[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)? { yylval.number = atof(yytext); return NUMBER; }
[a-zA-Z][a-zA-Z0-9]* { yylval.id = strdup(yytext); return IDENTIFIER; }
\"([^\\\"]|\\.)*\" { yylval.str = strdup(yytext); return STRING; }
. return *yytext;
%%