fix: lexer regex
This commit is contained in:
parent
2e989a60a3
commit
159a28c9fb
88
DragonLisp.l
88
DragonLisp.l
|
|
@ -27,38 +27,38 @@ blank [ \t\v\r]
|
||||||
comment ;[^\n\r]*
|
comment ;[^\n\r]*
|
||||||
string \"[^\r\n]*\"
|
string \"[^\r\n]*\"
|
||||||
|
|
||||||
and (and|AND)
|
and [aA][nN][dD]
|
||||||
or (or|OR)
|
or [oO][rR]
|
||||||
not (not|NOT)
|
not [nN][oO][tT]
|
||||||
max (max|MAX)
|
max [mM][aA][xX]
|
||||||
min (min|MIN)
|
min [mM][iI][nN]
|
||||||
if (if|IF)
|
if [iI][fF]
|
||||||
logand (logand|LOGAND)
|
logand [lL][oO][gG][aA][nN][dD]
|
||||||
logior (logior|LOGIOR)
|
logior [lL][oO][gG][iI][oO][rR]
|
||||||
logxor (logxor|LOGXOR)
|
logxor [lL][oO][gG][xX][oO][rR]
|
||||||
lognor (lognor|LOGNOR)
|
lognor [lL][oO][gG][nN][oO][rR]
|
||||||
logeqv (logeqv|LOGEQV)
|
logeqv [lL][oO][gG][eE][qQ][vV]
|
||||||
mod (mod|MOD)
|
mod [mM][oO][dD]
|
||||||
rem (rem|REM)
|
rem [rR][eE][mM]
|
||||||
incf (incf|INCF)
|
incf [iI][nN][cC][fF]
|
||||||
decf (decf|DECF)
|
decf [dD][eE][cC][fF]
|
||||||
defvar (defvar|DEFVAR)
|
defvar [dD][eE][fF][vV][aA][rR]
|
||||||
defun (defun|DEFUN)
|
defun [dD][eE][fF][uU][nN]
|
||||||
print (print|PRINT)
|
print [pP][rR][iI][nN][tT]
|
||||||
loop (loop|LOOP)
|
loop [lL][oO][oO][pP]
|
||||||
setq (setq|SETQ)
|
setq [sS][eE][tT][qQ]
|
||||||
setf (setf|SETF)
|
setf [sS][eE][tT][fF]
|
||||||
quote (quote|QUOTE)
|
quote [qQ][uU][oO][tT][eE]
|
||||||
for (for|FOR)
|
for [fF][oO][rR]
|
||||||
in (in|IN)
|
in [iI][nN]
|
||||||
from (from|FROM)
|
from [fF][rR][oO][mM]
|
||||||
to (to|TO)
|
to [tT][oO]
|
||||||
dotimes (dotimes|DOTIMES)
|
dotimes [dD][oO][tT][iI][mM][eE][sS]
|
||||||
dolist (dolist|DOLIST)
|
dolist [dD][oO][lL][iI][sS][tT]
|
||||||
do (do|DO)
|
do [dD][oO]
|
||||||
aref (aref|AREF)
|
aref [aA][rR][eE][fF]
|
||||||
makearray (make-array|MAKE-ARRAY)
|
makearray [mM][aA][kK][eE][-][aA][rR][rR][aA][yY]
|
||||||
defconstant (defconstant|DEFCONSTANT)
|
defconstant [dD][eE][fF][cC][oO][nN][sS][tT][aA][nN][tT]
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
|
@ -66,18 +66,6 @@ defconstant (defconstant|DEFCONSTANT)
|
||||||
yylval = lval;
|
yylval = lval;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
{string} {
|
|
||||||
loc->step();
|
|
||||||
std::printf("Scanned string: %s\n", yytext);
|
|
||||||
yylval->emplace<std::string>(std::string(yytext + 1, yyleng - 2));
|
|
||||||
return token::TOKEN_STRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
{comment} {
|
|
||||||
std::printf("Scanned comment: %s\n", yytext);
|
|
||||||
loc->step();
|
|
||||||
}
|
|
||||||
|
|
||||||
{blank}+ {
|
{blank}+ {
|
||||||
loc->step();
|
loc->step();
|
||||||
std::printf("Skipping blank\n");
|
std::printf("Skipping blank\n");
|
||||||
|
|
@ -337,6 +325,18 @@ defconstant (defconstant|DEFCONSTANT)
|
||||||
return token::TOKEN_DEFCONSTANT;
|
return token::TOKEN_DEFCONSTANT;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
{string} {
|
||||||
|
loc->step();
|
||||||
|
std::printf("Scanned string: %s\n", yytext);
|
||||||
|
yylval->emplace<std::string>(std::string(yytext + 1, yyleng - 2));
|
||||||
|
return token::TOKEN_STRING;
|
||||||
|
}
|
||||||
|
|
||||||
|
{comment} {
|
||||||
|
std::printf("Scanned comment: %s\n", yytext);
|
||||||
|
loc->step();
|
||||||
|
}
|
||||||
|
|
||||||
{id} {
|
{id} {
|
||||||
std::printf("Scanned identifier: %s\n", yytext);
|
std::printf("Scanned identifier: %s\n", yytext);
|
||||||
yylval->emplace<std::string>(std::string(yytext, yyleng));
|
yylval->emplace<std::string>(std::string(yytext, yyleng));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue