summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-11 00:19:36 -0400
committerbd <bdunahu@operationnull.com>2025-04-11 00:19:36 -0400
commit57bf0a940b3d1fdbe13684f545f0ce8707cdcd35 (patch)
treee33f252030e580cc7e60df69f413aa5a19ee4b3e /src
parentc02164cfee4d8c3d3eca76fa8cc60b6ca60c2ca0 (diff)
Add comments to parsing
Diffstat (limited to 'src')
-rw-r--r--src/parse.lisp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/parse.lisp b/src/parse.lisp
index 73e98c5..8eca782 100644
--- a/src/parse.lisp
+++ b/src/parse.lisp
@@ -9,10 +9,13 @@
(+ (or #\space #\tab))
(:constant nil))
-(esrap:defrule nl (+ #\newline)
+(esrap:defrule eol (and (esrap:? space) (esrap:? (and #\; (* (not #\newline)))) #\newline)
(:constant nil))
-(esrap:defrule nl-inc (+ #\newline)
+(esrap:defrule nl (+ eol)
+ (:constant nil))
+
+(esrap:defrule nl-inc (+ eol)
(:lambda (n)
(declare (ignore n))
(incf line-number)
@@ -139,10 +142,10 @@ DESTRUCTURE-PATTERN is the list of non-terminals on the right side of the gramma
;;; defines rules to parse the .text segment
-(esrap:defrule instr-clean (and (esrap:? space) instr (esrap:? space) nl-inc)
+(esrap:defrule instr-clean (and (esrap:? space) instr nl-inc)
(:function cadr))
-(esrap:defrule label-clean (and label-decl (esrap:? space) nl)
+(esrap:defrule label-clean (and label-decl nl)
(:function car))
(esrap:defrule text-line (or instr-clean label-clean))
@@ -164,7 +167,7 @@ DESTRUCTURE-PATTERN is the list of non-terminals on the right side of the gramma
(util:add-variable e var-offset)
nil))
-(esrap:defrule data-line (and (esrap:? space) var-decl (+ data-word) (esrap:? space) nl)
+(esrap:defrule data-line (and (esrap:? space) var-decl (+ data-word) nl)
(:function caddr))
(esrap:defrule data (and ".DATA" (esrap:? space) nl (* data-line))