feat: function def

This commit is contained in:
Eatswap 2022-12-11 17:57:42 +08:00
parent e8d1b6dd63
commit 6e9195c767
Signed by: Eatswap
GPG Key ID: BE661106A1F3FA0B
1 changed files with 11 additions and 6 deletions

View File

@ -96,15 +96,21 @@ namespace DragonLisp {
%%
S
: END { std::printf("Parsed S -> END\n"); }
| S-Exprs END { std::printf("Parsed S -> S-Exprs END\n"); }
: END { std::printf("Parsed S -> END\n"); }
| statements END { std::printf("Parsed S -> statements END\n"); }
;
statements
: S-Exprs { std::printf("Parsed statements -> S-Exprs\n"); }
| func-def { std::printf("Parsed statements -> func-def\n"); }
| statements S-Exprs { std::printf("Parsed statements -> statements S-Exprs\n"); }
| statements func-def { std::printf("Parsed statements -> statements func-def\n"); }
;
S-Exprs
: S-Exprs S-Expr { std::printf("Parsed S-Exprs -> S-Exprs S-Expr\n"); }
| S-Expr { std::printf("Parsed S-Exprs -> S-Expr\n"); }
;
;
R-Value
: IDENTIFIER { std::printf("Parsed R-Value -> IDENTIFIER\n"); }
@ -131,7 +137,6 @@ S-Expr-helper
| S-Expr-list { std::printf("Parsed S-Expr-helper -> S-Expr-list\n"); }
| S-Expr-if { std::printf("Parsed S-Expr-helper -> S-Expr-if\n"); }
| S-Expr-loop { std::printf("Parsed S-Expr-helper -> S-Expr-loop\n"); }
| S-Expr-func-def { std::printf("Parsed S-Expr-helper -> S-Expr-func-def\n"); }
| S-Expr-func-call { std::printf("Parsed S-Expr-helper -> S-Expr-func-call\n"); }
;
@ -204,8 +209,8 @@ S-Expr-loop
| 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
: 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"); }
func-def
: DEFUN IDENTIFIER LPAREN identifier-list RPAREN ignored-func-doc S-Exprs { std::printf("Parsed func-def -> DEFUN IDENTIFIER LPAREN identifier-list RPAREN ignored-func-doc S-Exprs\n"); }
;
ignored-func-doc