From b632667ce57af89691407bb8668e1512775278ae Mon Sep 17 00:00:00 2001 From: Calvin Date: Fri, 15 Mar 2013 15:26:20 -0400 Subject: nbc added --- src/nbc/substitution.grm | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/nbc/substitution.grm (limited to 'src/nbc/substitution.grm') diff --git a/src/nbc/substitution.grm b/src/nbc/substitution.grm new file mode 100644 index 0000000..58505b5 --- /dev/null +++ b/src/nbc/substitution.grm @@ -0,0 +1,50 @@ +%% +%name SubstitutionGrm +%pos int +%arg (lookup): string -> string +%term + DOLLAR + | TEXT of string + | LEFT_PARENTHESIS + | LEFT_BRACE + | RIGHT_PARENTHESIS + | RIGHT_BRACE + | EOF +%nonterm + STRING of string + | LIST of string list + | PORTION of string + | VARIABLE of string + | PARENTHESIZED of string list + | INSIDE_PARENTHESES of string list + | BRACED of string list + | INSIDE_BRACES of string list +%eop EOF +%noshift EOF +%start STRING +%% +STRING: LIST (concat LIST) +LIST: + (nil) + | PORTION LIST (PORTION :: LIST) +PORTION: + TEXT (TEXT) + | VARIABLE (lookup VARIABLE) +VARIABLE: + DOLLAR TEXT (TEXT) + | PARENTHESIZED (concat PARENTHESIZED) + | BRACED (concat BRACED) +PARENTHESIZED: + LEFT_PARENTHESIS INSIDE_PARENTHESES RIGHT_PARENTHESIS (INSIDE_PARENTHESES) +INSIDE_PARENTHESES: + (nil) + | TEXT INSIDE_PARENTHESES (TEXT :: INSIDE_PARENTHESES) + | LEFT_PARENTHESIS INSIDE_PARENTHESES RIGHT_PARENTHESIS INSIDE_PARENTHESES + ("(" :: INSIDE_PARENTHESES1 @ ")" :: INSIDE_PARENTHESES2) +BRACED: + LEFT_BRACE INSIDE_BRACES RIGHT_BRACE (INSIDE_BRACES) +INSIDE_BRACES: + (nil) + | TEXT INSIDE_BRACES (TEXT :: INSIDE_BRACES) + | LEFT_BRACE INSIDE_BRACES RIGHT_BRACE INSIDE_BRACES + ("{" :: INSIDE_BRACES1 @ "}" :: INSIDE_BRACES2) -- cgit v1.2.3