blob: 145b975473ef30457fbdfd8f7e8e88e95f96d3e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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.
|