simplify grammar
parent
c574ce3b54
commit
9b2fa914f5
@ -1,21 +1,17 @@
|
||||
#lang brag
|
||||
|
||||
;; rule of thumb: use [optional] bits judiciously as they multiply the cases needed for a production rule
|
||||
;; rule of thumb: for a set of related IDs, put each into the same grammar entity
|
||||
;; rule of thumb: avoid mushing unrelated IDs into one grammar entity
|
||||
;; whereas a * corresponds directly to an ... in the expander macro
|
||||
;; syntax patterns are good for
|
||||
;; + single case / nonrecursive structure
|
||||
;; + nonalternating pattern (no "this that this that ...")
|
||||
chip-program : /"CHIP" chipname /"{" pin-spec pin-spec part-spec /"}"
|
||||
|
||||
chip-program : "CHIP" ID "{" pin-spec pin-spec part-spec "}"
|
||||
@chipname : ID
|
||||
|
||||
pin-spec : ("IN" | "OUT") pin+ ";"
|
||||
pin-spec : (/"IN" | /"OUT") pin [/"," pin]* /";"
|
||||
|
||||
pin : ID [","]
|
||||
@pin : ID
|
||||
|
||||
part-spec : "PARTS:" part+
|
||||
part-spec : /"PARTS:" part+
|
||||
|
||||
part : ID "(" pin-val-pair+ ")" ";"
|
||||
part : partname /"(" pin-val-pair [/"," pin-val-pair]* /")" /";"
|
||||
|
||||
pin-val-pair : ID "=" ID [","]
|
||||
@partname : ID
|
||||
|
||||
/pin-val-pair : pin /"=" ID
|
Loading…
Reference in New Issue