summaryrefslogtreecommitdiff
path: root/old/cocoebnf/EBNF.atg
diff options
context:
space:
mode:
Diffstat (limited to 'old/cocoebnf/EBNF.atg')
-rw-r--r--old/cocoebnf/EBNF.atg51
1 files changed, 51 insertions, 0 deletions
diff --git a/old/cocoebnf/EBNF.atg b/old/cocoebnf/EBNF.atg
new file mode 100644
index 0000000..145b975
--- /dev/null
+++ b/old/cocoebnf/EBNF.atg
@@ -0,0 +1,51 @@
+#include <iostream>
+#include <wchar.h>
+
+COMPILER EBNF
+
+CHARACTERS
+
+Letter = 'A' .. 'Z' + 'a' .. 'z' .
+Digit = '0' .. '9' .
+StringChar = ANY - "\"" .
+
+cr = '\r' .
+lf = '\n' .
+tab = '\t' .
+
+TOKENS
+
+Ident = Letter { Letter | Digit } .
+
+String = "\"" { StringChar } "\"" .
+
+IGNORE cr + lf + tab
+
+PRODUCTIONS
+
+EBNF = { Production } .
+
+Production = (. wchar_t *name; .)
+Identifier<name> (. coco_string_delete( name ); .)
+"="
+Expression
+"."
+.
+
+Expression = Term { "|" Term } .
+
+Term = Factor { Factor } .
+
+Factor = (. wchar_t *name; .)
+Identifier<name> (. std::wcout << "ident: " << name << std::endl;
+ coco_string_delete( name ); .)
+|
+String (. std::wcout << "literal: " << t->val << std::endl; .)
+|
+"(" Expression ")" | "[" Expression "]" | "{" Expression "}" .
+
+Identifier<wchar_t* &name>
+= Ident (. name = coco_string_create( t->val ); .)
+.
+
+END EBNF.