diff options
Diffstat (limited to 'src/bnf.bnf')
-rw-r--r-- | src/bnf.bnf | 81 |
1 files changed, 55 insertions, 26 deletions
diff --git a/src/bnf.bnf b/src/bnf.bnf index df8ef3c..0a339fc 100644 --- a/src/bnf.bnf +++ b/src/bnf.bnf @@ -1,27 +1,41 @@ # A grammar file for reading BNF notation +# FIXME: Too many errors! -[id]: a-zA-Z-_+*@ +[space]: %x20\t -[notbracket]: ^[] +[id]: a-zA-Z\-_+*@ + +[rule_name_char]: ^[]:%x20\n [notnewline]: ^\n\r +[class_range_char]: ^\n\r\^\\ + +[class_single_char]: ^\n\r\^\\\- + +[any]: + +[double_string_char]: ^"\n + +[single_string_char]: ^'\n + -- -BNF: predicate_section "--\n" rules_section +BNF: "#" notnewlines empty BNF +BNF: predicate_section "--\n" empty rules_section BNF: rules_section BNF: -spaces: space spaces -spaces: space +spaces: [space] spaces +spaces: [space] -space: " " -space: "\t" +optional_spaces: [space] optional_spaces +optional_spaces: -empty: spaces empty -empty: "\n" empty "\n" -empty: "\r" empty "\n" -empty: "#" notnewlines "\n" +empty: [space] empty +empty: "\n" empty +empty: "\r" empty +empty: "\n#" notnewlines empty: notnewlines: [notnewline] notnewlines @@ -30,13 +44,13 @@ notnewlines: predicate_section: predicate empty "\n" predicate_section predicate_section: -predicate: "[" ids "]:" spaces class +predicate: "[" ids "]:" optional_spaces class ids: [id] ids -ids: +ids: [id] # Yes, a class specification can be empty, in which case the predicate -# is equivalent with the default "any" predicate. +# matches everything. class: positive_class class: "^" positive_class @@ -44,23 +58,38 @@ class: "^" positive_class positive_class: positive_specification positive_class positive_class: -positive_specification: enotnewline -positive_specification: enotnewline "-" enotnewline +positive_specification: class_single_chars +positive_specification: class_range_chars "-" class_range_chars + +class_single_chars: [class_single_char] +class_single_chars: "\\" [any] -# Extended not-newline, or escaped not-newline -enotnewline: [notnewline] -enotnewline: "\\" [any] +class_range_chars: [class_range_char] +class_range_chars: "\\" [any] rules_section: rule empty "\n" rules_section +rules_section: -rule: rule_name ":" spaces rule_rhs -rule: rule_name ":" rule_rhs +rule: rule_name optional_spaces ":" optional_spaces rule_rhs -rule_name: [notbracket] rule_name +rule_name: [rule_name_char] rule_name rule_name: -spaces-or-escaped-newline: spaces -spaces-or-escaped-newline: "\\\n" +spaces_or_escaped_newline: optional_spaces +spaces_or_escaped_newline: "\\\n" + +rule_rhs: ids spaces_or_escaped_newline rule_rhs +rule_rhs: '[' ids ']' spaces_or_escaped_newline rule_rhs +rule_rhs: '"' double_string_chars '"' spaces_or_escaped_newline rule_rhs +rule_rhs: "'" single_string_chars "'" spaces_or_escaped_newline rule_rhs +rule_rhs: + +double_string_chars: [double_string_char] +double_string_chars: "\\" [any] +double_string_chars: [double_string_char] double_string_char +double_string_chars: "\\" [any] double_string_chars -rule_rhs: ids spaces-or-escaped-newline rule_rhs -rule_rhs: +single_string_chars: [single_string_char] +single_string_chars: "\\" [any] +single_string_chars: [single_string_char] single_string_char +single_string_chars: "\\" [any] single_string_chars |