-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
abbParser.g4
110 lines (87 loc) · 2.17 KB
/
abbParser.g4
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
// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false
// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging
parser grammar abbParser;
options {
tokenVocab = abbLexer;
}
/*
This grammar is still in development.
In the current state, it is only able to parse .sys-files and read the given declarations.
*/
/*
This file is the grammar for the ABB RAPID Robot Language.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Antlr4 port by Tom Everett, 2016
Question mark stands for: zero or one
Plus stands for: one or more
Star stands for: zero or more
*/
module_
: moduleData EOF
;
moduleData
: MODULE moduleName NEWLINE dataList NEWLINE* ENDMODULE
;
moduleName
: IDENTIFIER
| procCall
;
dataList
: (NEWLINE | declaration NEWLINE | procedure NEWLINE)*
;
procedure
: PROC procCall NEWLINE (functionCall NEWLINE)* ENDPROC
;
procCall
: procName procParameter?
;
procName
: IDENTIFIER
;
procParameter
: BRACKET_OPEN IDENTIFIER? BRACKET_CLOSE
;
functionCall
: IDENTIFIER (functionParameter COMMA)* functionParameter SEMICOLON
;
functionParameter
: ON_CALL
| OFF_CALL
| primitive
| IDENTIFIER
;
declaration
: init_ type_ IDENTIFIER (EQUALS expression)? SEMICOLON
;
type_
: TOOLDATA
| WOBJDATA
| SPEEDDATA
| ZONEDATA
| CLOCK
| BOOL
;
init_
: LOCAL? (CONST | PERS | VAR)
;
expression
: array_
| primitive
;
array_
: SQUARE_OPEN (expression COMMA)* expression SQUARE_CLOSE
;
primitive
: BOOLLITERAL
| CHARLITERAL
| STRINGLITERAL
| (PLUS | MINUS)? FLOATLITERAL
| (PLUS | MINUS)? INTLITERAL
;