3e0f9b8a
Francisco Coelho
back to work?
|
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
A more formal description
A more formal description of the proposed Interchange Format is given
here. The notation used by the Jack parser generator is used here.
In the description below, the patterns used by the lexer to define
tokens are very similar to regular expressions used by the Unix regexp
facility. Non-terminals have a parenthesis pair "()" after their
names; terminals are usually capitalized. Some structures that may
appear in expansions are:
( e )? : An optional occurrence of e
e1 | e2 | e3 | ... : A choice of e1, e2, e3, etc.
( e )+ : One or more occurrences of e
( e )* : Zero or more occurrences of e
["a"-"z"] matches all lower case letters
~["\n","\r"] matches any character except the new line characters
--------------------------------------------------------------------------------
The following patterns are ignored when they appear between tokens:
" "
"\t"
"\n"
"\r"
"//" (~["\n","\r"])* ("\n"|"\r\n")
"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"
","
"|"
--------------------------------------------------------------------------------
The definition of a word is:
WORD: LETTER (LETTER | DIGIT)*
LETTER: ["a"-"z","A"-"Z","_","-"]
DIGIT: ["0"-"9"]
--------------------------------------------------------------------------------
The definition of a non-negative integer number is:
DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])*
--------------------------------------------------------------------------------
The definition of a non-negative real number is:
FLOATING_POINT_LITERAL: (["0"-"9"])+ "." (["0"-"9"])* (EXPONENT)?
| "." (["0"-"9"])+ (EXPONENT)?
| (["0"-"9"])+ (EXPONENT)?
#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+
--------------------------------------------------------------------------------
The following words are keywords:
NETWORK: "network"
VARIABLE: "variable"
PROBABILITY: "probability"
PROPERTY: "property"
VARIABLETYPE: "type"
DISCRETE: "discrete"
DEFAULTVALUE: "default"
TABLEVALUES: "table"
--------------------------------------------------------------------------------
A property is defined as:
PROPERTYSTRING: PROPERTY (~[";"])* ";"
--------------------------------------------------------------------------------
The productions of the grammar are:
CompilationUnit() :
NetworkDeclaration()
( VariableDeclaration() | ProbabilityDeclaration() )*
EOF
NetworkDeclaration() :
NETWORK WORD NetworkContent()
NetworkContent() :
"{" ( Property() )* "}"
VariableDeclaration() :
VARIABLE ProbabilityVariableName() VariableContent()
VariableContent(String name) :
"{" ( Property() | VariableDiscrete() )* "}"
VariableDiscrete() :
VARIABLETYPE DISCRETE
"[" DECIMAL_LITERAL "]" "{" VariableValuesList() "}" ";"
void VariableValuesList() :
ProbabilityVariableValue()
( ProbabilityVariableValue() )*
ProbabilityVariableValue() : WORD
ProbabilityDeclaration() :
PROBABILITY ProbabilityVariablesList() ProbabilityContent()
ProbabilityVariablesList() :
"(" ProbabilityVariableName() ( ProbabilityVariableName() )* ")"
ProbabilityVariableName() :
ProbabilityContent()
"{" ( Property() | ProbabilityDefaultEntry() | ProbabilityEntry()
|
ProbabilityTable() )* "}"
ProbabilityEntry() :
ProbabilityValuesList() FloatingPointList() ";"
ProbabilityValuesList() :
"(" ProbabilityVariableValue() ( ProbabilityVariableValue() )*
")"
ProbabilityDefaultEntry() :
FloatingPointList() ";"
ProbabilityTable() :
FloatingPointList() ";"
FloatingPointList() :
FloatingPointToken() ( FloatingPointToken() )*
FloatingPointToken() :
Property() :
|