-
Notifications
You must be signed in to change notification settings - Fork 12
/
SemEnglish.g
71 lines (45 loc) · 1.45 KB
/
SemEnglish.g
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
transcribed from
http://robustai.net/mentography/SyntaxSemenglish7.gif
Last Modified: Sunday, 22-Jul-01 19:59:51 GMT
other sources:
SemEnglish Primer
Created 2001/1/26 last revised 2001/3/25
pronounced `sem.Eng.lish
http://robustai.net/mentography/semenglish.html
"""
%%
parser SemEnglish:
ignore: r'[ \r\n\t\f]+'
token Dquote: r'"[^\"]*"'
token Squote: r"'[^\']*'"
token Number: r'[0-9]+' # decimals? e-notation?
token THAT: "that"
token Word: r'[^ \n\r\t\f"\)\({}\[\];]*[^ \n\r\t\f"\)\({}\[\];\.0-9]' # @@not single quotes either
token END: "\Z"
rule document: Statement* END
rule Statement: Subject Predicate AddPredicate* ["\\."]
{{ print "@@got one statement" }}
rule Subject: CompoundWords
| Word
| Number
| AnnNode
rule CompoundWords: "\\(" Word+ "\\)"
rule AnnNode: "\\[" Predicate "\\]"
rule Predicate: Verb Object AddObject*
rule AddPredicate: ";" Predicate
rule Verb: CompoundWords
| Word
rule Object: CompoundWords
| ExpObject
| Expression
rule AddObject: "," Object
rule ExpObject: Word | Number | AnnNode
| ReifiedStatement | Context | Literal
rule ReifiedStatement: THAT "\\(" Subject Verb Object "\\)"
rule Context: "{" Statement* "}"
rule Literal: Dquote | Squote
rule Expression: "exp" Nexpression
rule Nexpression: "\\(" Verb ExpObject_ + "\\)"
rule ExpObject_ : ExpObject
| Nexpression