From 9cf07f59514b7c48ee31036b729d50736cf9c0db Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Thu, 12 Jul 2012 16:58:46 -0400 Subject: [PATCH] Added comment to parser describing the EBNF grammar I hope to implement --- source/parser.scm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/parser.scm b/source/parser.scm index bdcd7a0..e64f670 100644 --- a/source/parser.scm +++ b/source/parser.scm @@ -1,5 +1,22 @@ (declare (unit parser) (uses buf)) +; Formal EBNF Syntax: +; +; Program := Expression* +; +; Expression := CoreForm +; | BasicExpr +; | BasicExpr ArgList +; CoreForm +; +; BasicExpr := '(' Expression Operator Expression ')' +; | Literal +; +; Operator +; +; Literal := ID | CHAR | STRING | SYMBOL | NUMBER +; +; ArgList := '(' Expression (',' Expression)* ')' (define (dlang/program in) (define result '()) @@ -21,7 +38,8 @@ (define (dlang/core-form in) '()) (define (dlang/basic-expr in) - (if (buf-lookahead! in 1) + (define tok (buf-lookahead! in 1)) + (if (equal? 'lpar (token-type tok)) (dlang/operator-app in) (dlang/literal in))) -- 2.52.0