From 57bf0a940b3d1fdbe13684f545f0ce8707cdcd35 Mon Sep 17 00:00:00 2001 From: bd Date: Fri, 11 Apr 2025 00:19:36 -0400 Subject: Add comments to parsing --- src/parse.lisp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') 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)) -- cgit v1.2.3