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
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)*] "]"
object: <"{"> [kvpair ("," kvpair)*] <"}">
object: !"{" [kvpair ("," kvpair)*] !"}"
<kvpair>: <ID> ":" <json>
!kvpair : !ID ":" !json

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

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

Loading…
Cancel
Save