You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
beautiful-racket/beautiful-racket/br/demo/hdl/parser.rkt

21 lines
681 B
Racket

#lang brag
8 years ago
8 years ago
;; 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 ...")
8 years ago
8 years ago
chip-program : "CHIP" ID "{" pin-spec pin-spec part-spec "}"
8 years ago
pin-spec : ("IN" | "OUT") pin+ ";"
8 years ago
8 years ago
pin : ID [","]
8 years ago
8 years ago
part-spec : "PARTS:" part+
8 years ago
part : ID "(" pin-val-pair+ ")" ";"
8 years ago
8 years ago
pin-val-pair : ID "=" ID [","]