fix: no spaces

This commit is contained in:
Eatswap 2022-12-11 17:50:05 +08:00
parent ecf948e382
commit e8d1b6dd63
Signed by: Eatswap
GPG Key ID: BE661106A1F3FA0B
2 changed files with 75 additions and 76 deletions

View File

@ -78,14 +78,14 @@ defconstant (defconstant|DEFCONSTANT)
{blank}+ { {blank}+ {
loc->step(); loc->step();
std::printf("Skipping blank\n"); std::printf("Skipping blank\n");
return token::TOKEN_SPACE; // return token::TOKEN_SPACE;
}; };
\n+ { \n+ {
loc->lines(yyleng); loc->lines(yyleng);
loc->step(); loc->step();
std::printf("Skipping newline\n"); std::printf("Skipping newline\n");
return token::TOKEN_SPACE; // return token::TOKEN_SPACE;
} }
{float} { {float} {

View File

@ -96,131 +96,130 @@ namespace DragonLisp {
%% %%
S S
: END : END { std::printf("Parsed S -> END\n"); }
| S-Exprs END | S-Exprs END { std::printf("Parsed S -> S-Exprs END\n"); }
; ;
S-Exprs S-Exprs
: S-Exprs empty S-Expr : S-Exprs S-Expr { std::printf("Parsed S-Exprs -> S-Exprs S-Expr\n"); }
| S-Expr | S-Expr { std::printf("Parsed S-Exprs -> S-Expr\n"); }
; ;
spaces
: SPACE
| spaces SPACE
;
empty
:
| spaces
; ;
R-Value R-Value
: IDENTIFIER : IDENTIFIER { std::printf("Parsed R-Value -> IDENTIFIER\n"); }
| literal | S-Expr { std::printf("Parsed R-Value -> S-Expr\n"); }
| S-Expr | INTEGER { std::printf("Parsed R-Value -> INTEGER\n"); }
| FLOAT { std::printf("Parsed R-Value -> FLOAT\n"); }
S-Expr | STRING { std::printf("Parsed R-Value -> STRING\n"); }
: LPAREN empty S-Expr-helper empty RPAREN
| LPAREN empty RPAREN
; ;
literal R-Value-list
: INTEGER : R-Value { std::printf("Parsed R-Value-list -> R-Value\n"); }
| FLOAT | R-Value-list R-Value { std::printf("Parsed R-Value-list -> R-Value-list R-Value\n"); }
| STRING ;
S-Expr
: LPAREN S-Expr-helper RPAREN { std::printf("Parsed S-Expr -> LPAREN S-Expr-helper RPAREN\n"); }
| LPAREN RPAREN { std::printf("Parsed S-Expr -> LPAREN RPAREN\n"); }
; ;
S-Expr-helper S-Expr-helper
: S-Expr-var-op : S-Expr-var-op { std::printf("Parsed S-Expr-helper -> S-Expr-var-op\n"); }
| S-Expr-unary | S-Expr-unary { std::printf("Parsed S-Expr-helper -> S-Expr-unary\n"); }
| S-Expr-binary | S-Expr-binary { std::printf("Parsed S-Expr-helper -> S-Expr-binary\n"); }
| S-Expr-list | S-Expr-list { std::printf("Parsed S-Expr-helper -> S-Expr-list\n"); }
| S-Expr-if | S-Expr-if { std::printf("Parsed S-Expr-helper -> S-Expr-if\n"); }
| S-Expr-loop | S-Expr-loop { std::printf("Parsed S-Expr-helper -> S-Expr-loop\n"); }
| S-Expr-func-def | S-Expr-func-def { std::printf("Parsed S-Expr-helper -> S-Expr-func-def\n"); }
| S-Expr-func-call | S-Expr-func-call { std::printf("Parsed S-Expr-helper -> S-Expr-func-call\n"); }
; ;
S-Expr-var-op S-Expr-var-op
: var-op-tokens spaces IDENTIFIER spaces R-Value : var-op-tokens IDENTIFIER R-Value { std::printf("Parsed S-Expr-var-op -> var-op-tokens IDENTIFIER R-Value\n"); }
; ;
var-op-tokens var-op-tokens
: DEFVAR : DEFVAR { std::printf("Parsed var-op-tokens -> DEFVAR\n"); }
| SETQ | SETQ { std::printf("Parsed var-op-tokens -> SETQ\n"); }
| INCF | INCF { std::printf("Parsed var-op-tokens -> INCF\n"); }
| DECF | DECF { std::printf("Parsed var-op-tokens -> DECF\n"); }
| DEFCONSTANT | DEFCONSTANT { std::printf("Parsed var-op-tokens -> DEFCONSTANT\n"); }
; ;
S-Expr-unary S-Expr-unary
: unary-tokens spaces R-Value : unary-tokens R-Value { std::printf("Parsed S-Expr-unary -> unary-tokens R-Value\n"); }
; ;
unary-tokens unary-tokens
: NOT : NOT { std::printf("Parsed unary-tokens -> NOT\n"); }
| PRINT | PRINT { std::printf("Parsed unary-tokens -> PRINT\n"); }
; ;
S-Expr-binary S-Expr-binary
: binary-tokens spaces S-Expr empty S-Expr : binary-tokens R-Value R-Value { std::printf("Parsed S-Expr-binary -> binary-tokens R-Value R-Value\n"); }
; ;
binary-tokens binary-tokens
: LESS : LESS { std::printf("Parsed binary-tokens -> LESS\n"); }
| LESS_EQUAL | LESS_EQUAL { std::printf("Parsed binary-tokens -> LESS_EQUAL\n"); }
| GREATER | GREATER { std::printf("Parsed binary-tokens -> GREATER\n"); }
| GREATER_EQUAL | GREATER_EQUAL { std::printf("Parsed binary-tokens -> GREATER_EQUAL\n"); }
| LOGNOR | LOGNOR { std::printf("Parsed binary-tokens -> LOGNOR\n"); }
| MOD | MOD { std::printf("Parsed binary-tokens -> MOD\n"); }
| REM | REM { std::printf("Parsed binary-tokens -> REM\n"); }
; ;
S-Expr-list S-Expr-list
: list-tokens spaces S-Exprs : list-tokens R-Value-list { std::printf("Parsed S-Expr-list -> list-tokens R-Value-list\n"); }
; ;
list-tokens list-tokens
: EQUAL : EQUAL { std::printf("Parsed list-tokens -> EQUAL\n"); }
| NOT_EQUAL | NOT_EQUAL { std::printf("Parsed list-tokens -> NOT_EQUAL\n"); }
| AND | AND { std::printf("Parsed list-tokens -> AND\n"); }
| OR | OR { std::printf("Parsed list-tokens -> OR\n"); }
| MAX | MAX { std::printf("Parsed list-tokens -> MAX\n"); }
| MIN | MIN { std::printf("Parsed list-tokens -> MIN\n"); }
| LOGAND | LOGAND { std::printf("Parsed list-tokens -> LOGAND\n"); }
| LOGIOR | LOGIOR { std::printf("Parsed list-tokens -> LOGIOR\n"); }
| LOGXOR | LOGXOR { std::printf("Parsed list-tokens -> LOGXOR\n"); }
| LOGEQV | LOGEQV { std::printf("Parsed list-tokens -> LOGEQV\n"); }
| PLUS | PLUS { std::printf("Parsed list-tokens -> PLUS\n"); }
| MINUS | MINUS { std::printf("Parsed list-tokens -> MINUS\n"); }
| MULTIPLY | MULTIPLY { std::printf("Parsed list-tokens -> MULTIPLY\n"); }
| DIVIDE | DIVIDE { std::printf("Parsed list-tokens -> DIVIDE\n"); }
; ;
S-Expr-if S-Expr-if
: IF spaces S-Expr empty S-Expr empty S-Expr : IF R-Value R-Value R-Value { std::printf("Parsed S-Expr-if -> IF R-Value R-Value R-Value\n"); }
| IF R-Value R-Value { std::printf("Parsed S-Expr-if -> IF R-Value R-Value\n"); }
; ;
S-Expr-loop S-Expr-loop
: LOOP empty S-Exprs : LOOP S-Exprs { std::printf("Parsed S-Expr-loop -> LOOP S-Exprs\n"); }
| LOOP spaces FOR spaces IDENTIFIER spaces IN empty S-Expr empty DO empty S-Exprs | LOOP FOR IDENTIFIER IN S-Expr DO S-Exprs { std::printf("Parsed S-Expr-loop -> LOOP FOR IDENTIFIER IN S-Expr DO S-Exprs\n"); }
| LOOP spaces FOR spaces IDENTIFIER spaces FROM empty S-Expr empty TO empty S-Expr empty DO empty S-Exprs | LOOP FOR IDENTIFIER FROM S-Expr TO S-Expr DO S-Exprs { std::printf("Parsed S-Expr-loop -> LOOP FOR IDENTIFIER FROM S-Expr TO S-Expr DO S-Exprs\n"); }
| DOTIMES empty LPAREN empty IDENTIFIER empty S-Expr empty RPAREN empty S-Exprs | DOTIMES LPAREN IDENTIFIER S-Expr RPAREN S-Exprs { std::printf("Parsed S-Expr-loop -> DOTIMES LPAREN IDENTIFIER S-Expr RPAREN S-Exprs\n"); }
| DOLIST empty LPAREN empty IDENTIFIER empty S-Expr empty RPAREN empty S-Exprs | DOLIST LPAREN IDENTIFIER S-Expr RPAREN S-Exprs { std::printf("Parsed S-Expr-loop -> DOLIST LPAREN IDENTIFIER S-Expr RPAREN S-Exprs\n"); }
; ;
S-Expr-func-def S-Expr-func-def
: DEFUN spaces IDENTIFIER empty LPAREN empty identifier-list empty RPAREN ignored-func-doc S-Exprs : DEFUN IDENTIFIER LPAREN identifier-list RPAREN ignored-func-doc S-Exprs { std::printf("Parsed S-Expr-func-def -> DEFUN IDENTIFIER LPAREN identifier-list RPAREN ignored-func-doc S-Exprs\n"); }
; ;
ignored-func-doc ignored-func-doc
: empty STRING empty : { std::printf("Parsed ignored-func-doc -> \n"); }
| STRING { std::printf("Parsed ignored-func-doc -> STRING\n"); }
; ;
identifier-list identifier-list
: identifier-list IDENTIFIER : identifier-list IDENTIFIER { std::printf("Parsed identifier-list -> identifier-list IDENTIFIER\n"); }
| IDENTIFIER | IDENTIFIER { std::printf("Parsed identifier-list -> IDENTIFIER\n"); }
;
S-Expr-func-call
: IDENTIFIER R-Value-list { std::printf("Parsed S-Expr-func-call -> IDENTIFIER R-Value-list\n"); }
; ;
%% %%