summaryrefslogtreecommitdiff
path: root/src/bnf.bnf
diff options
context:
space:
mode:
Diffstat (limited to 'src/bnf.bnf')
-rw-r--r--src/bnf.bnf62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/bnf.bnf b/src/bnf.bnf
new file mode 100644
index 0000000..26e9861
--- /dev/null
+++ b/src/bnf.bnf
@@ -0,0 +1,62 @@
+# A grammar file for reading BNF notation
+
+[id]: a-zA-Z-_+*@
+
+[notbracket]: ^[]
+
+[notnewline]: ^\n\r
+
+--
+
+BNF: predicate_section "--\n" rules_section
+BNF: rules_section
+BNF:
+
+spaces: space spaces
+spaces:
+
+space: " "
+space: "\t"
+
+empty: spaces empty
+empty: "\n" empty "\n"
+empty: "\r" empty "\n"
+empty: "#" notnewlines "\n"
+empty:
+
+notnewlines: [notnewline] notnewlines
+notnewlines:
+
+predicate_section: predicate empty "\n" empty predicate_section
+predicate_section:
+
+predicate: "[" ids "]:" spaces class
+
+ids: [id] ids
+ids:
+
+# Yes, a class specification can be empty, in which case the predicate
+# is equivalent with the default "any" predicate.
+
+class: positive_class
+class: "^" positive_class
+
+positive_class: positive_specification positive_class
+positive_class:
+
+positive_specification: notnewline
+positive_specification: notnewline "-" notnewline
+
+notnewline: [notnewline]
+notnewline: "\\" [any]
+notnewline:
+
+rules_section: rule empty "\n" empty rules_section
+
+rule: rule_name ":" spaces rule_rhs
+
+rule_name: [notbracket] rule_name
+rule_name:
+
+rule_rhs: ids spaces rule_rhs
+rule_rhs: