use ! instead of <> for grammar hiding

pull/2/head
Matthew Butterick 8 years ago
parent 5d73d41174
commit f312677216

@ -2,26 +2,26 @@
txtadv-program : verb-section everywhere-section things-section places-section start-section txtadv-program : verb-section everywhere-section things-section places-section start-section
verb-section : <"===VERBS==="> verb-item+ verb-section : !"===VERBS===" verb-item+
<verb-item> : verb-name+ s-exp !verb-item : verb-name+ s-exp
<verb-name> : [<",">] ID ["_"] !verb-name : [!","] ID ["_"]
everywhere-section : <"===EVERYWHERE==="> id-desc+ everywhere-section : !"===EVERYWHERE===" id-desc+
things-section : <"===THINGS==="> thing-item+ things-section : !"===THINGS===" thing-item+
<thing-item> : DASHED-NAME id-desc+ !thing-item : DASHED-NAME id-desc+
places-section : <"===PLACES==="> place-item+ places-section : !"===PLACES===" place-item+
<place-item> : DASHED-NAME STRING place-items id-desc+ !place-item : DASHED-NAME STRING place-items id-desc+
<place-items> : <"["> ([<",">] ID)* <"]"> !place-items : !"[" ([!","] ID)* !"]"
start-section : <"===START==="> ID start-section : !"===START===" ID
<id-desc> : ID s-exp !id-desc : ID s-exp
s-exp : ID | STRING | <"("> s-exp* <")"> s-exp : ID | STRING | !"(" s-exp* !")"

@ -11,6 +11,6 @@ string: STRING
array: "[" [json ("," json)*] "]" array: "[" [json ("," json)*] "]"
object: <"{"> [kvpair ("," kvpair)*] <"}"> object: !"{" [kvpair ("," kvpair)*] !"}"
<kvpair>: <ID> ":" <json> !kvpair : !ID ":" !json

@ -14,7 +14,7 @@
(define-lex-abbrevs (define-lex-abbrevs
[letter (:or (:/ "a" "z") (:/ #\A #\Z))] [letter (:or (:/ "a" "z") (:/ #\A #\Z))]
[digit (:/ #\0 #\9)] [digit (:/ #\0 #\9)]
[id-char (:or letter digit (char-set "-.!$%&/=?^_~@"))] [id-char (:or letter digit (char-set "-.$%&/=?^_~<>"))]
) )
(define-lex-abbrev id (define-lex-abbrev id
@ -36,14 +36,14 @@
(token-LPAREN lexeme)] (token-LPAREN lexeme)]
["[" ["["
(token-LBRACKET lexeme)] (token-LBRACKET lexeme)]
["<"
(token-LANGLE lexeme)]
[")" [")"
(token-RPAREN lexeme)] (token-RPAREN lexeme)]
["]" ["]"
(token-RBRACKET lexeme)] (token-RBRACKET lexeme)]
[">" ["!"
(token-RANGLE lexeme)] (token-BANG lexeme)]
["@"
(token-ATSIGN lexeme)]
["|" ["|"
(token-PIPE lexeme)] (token-PIPE lexeme)]
[(:or "+" "*") [(:or "+" "*")
@ -61,7 +61,7 @@
(token-EOF lexeme)] (token-EOF lexeme)]
[(:: id (:* whitespace) ":") [(:: id (:* whitespace) ":")
(token-RULE_HEAD lexeme)] (token-RULE_HEAD lexeme)]
[(:: "<" id ">" (:* whitespace) ":") [(:: "!" id (:* whitespace) ":")
(token-RULE_HEAD_HIDDEN lexeme)] (token-RULE_HEAD_HIDDEN lexeme)]
[id [id
(token-ID lexeme)] (token-ID lexeme)]

@ -10,8 +10,8 @@
(provide tokens (provide tokens
token-LPAREN token-LPAREN
token-RPAREN token-RPAREN
token-LANGLE ; for elider token-BANG ; for hider
token-RANGLE ; for elider token-ATSIGN ; for splicer
token-LBRACKET token-LBRACKET
token-RBRACKET token-RBRACKET
token-PIPE token-PIPE
@ -41,8 +41,8 @@
RPAREN RPAREN
LBRACKET LBRACKET
RBRACKET RBRACKET
LANGLE BANG
RANGLE ATSIGN
PIPE PIPE
REPEAT REPEAT
RULE_HEAD RULE_HEAD
@ -88,10 +88,10 @@
#f) #f)
$2))] $2))]
;; angles indicate splicing. set splice value to #t ;; bang indicates hiding. set hide value to #t
[(RULE_HEAD_HIDDEN pattern) [(RULE_HEAD_HIDDEN pattern)
(begin (begin
(define trimmed (cadr (regexp-match #px"<(.+)>\\s*:$" $1))) (define trimmed (cadr (regexp-match #px"!(\\S+)\\s*:$" $1)))
(rule (position->pos $1-start-pos) (rule (position->pos $1-start-pos)
(position->pos $2-end-pos) (position->pos $2-end-pos)
(lhs-id (position->pos $1-start-pos) (lhs-id (position->pos $1-start-pos)
@ -168,9 +168,9 @@
[(LPAREN pattern RPAREN) [(LPAREN pattern RPAREN)
(relocate-pattern $2 (position->pos $1-start-pos) (position->pos $3-end-pos))] (relocate-pattern $2 (position->pos $1-start-pos) (position->pos $3-end-pos))]
[(LANGLE pattern RANGLE) [(BANG atomic-pattern)
;; angles indicate hiding. set hide value to #t ;; bang indicates hiding. set hide value to #t
(relocate-pattern $2 (position->pos $1-start-pos) (position->pos $3-end-pos) #t)]]) (relocate-pattern $2 (position->pos $1-start-pos) (position->pos $2-end-pos) #t)]])
(error (lambda (tok-ok? tok-name tok-value start-pos end-pos) (error (lambda (tok-ok? tok-name tok-value start-pos end-pos)

Loading…
Cancel
Save