-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli-grammar.gll
138 lines (107 loc) · 4.51 KB
/
cli-grammar.gll
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
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* M2C Modula-2 Compiler & Translator *
* *
* Copyright (c) 2015-2023 Benjamin Kowarsch *
* *
* @synopsis *
* *
* M2C is a portable Modula-2 to C translator and via-C compiler for the *
* bootstrap subset of the revised Modula-2 language described in *
* *
* https://github.com/m2sf/m2bsk/wiki/Language-Specification *
* *
* In translator mode, M2C translates Modula-2 source files to semantically *
* equivalent C source files. In compiler mode, it translates the Modula-2 *
* source files to C, then compiles the resulting C sources to object and *
* executable files using the host system's resident C compiler and linker. *
* *
* Further information at https://github.com/m2sf/m2c/wiki *
* *
* @file *
* *
* cli-grammar.gll *
* *
* EBNF grammar of the command line interface. *
* *
* @license *
* *
* M2C is free software: You can redistribute and modify it under the terms *
* of the GNU Lesser General Public License (LGPL) either version 2.1 or at *
* your choice version 3, both published by the Free Software Foundation. *
* *
* M2C is distributed in the hope it may be useful, but strictly WITHOUT ANY *
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
* FOR ANY PARTICULAR PURPOSE. Read the license for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with M2C. If not, see <https://www.gnu.org/copyleft/lesser.html>. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
grammar m2cli;
/* * * R e s e r v e d W o r d s * * */
/* to do */
/* * * N o n - T e r m i n a l S y m b o l s * * */
args :=
infoRequest | compilationRequest
;
infoRequest :=
--help | -h | --version | -V | --license
;
compilationRequest :=
products? capabilities? sourceFile diagnostics?
;
products :=
( singleProduct | multipleProducts ) commentOption?
;
singleProduct :=
--syntax-only | --ast-only | --graph-only | --xlat-only | --obj-only
;
multipleProducts :=
( ast | graph | xlat | obj )+
;
ast :=
--ast | --no-ast
;
graph :=
--graph | --no-graph
;
xlat :=
--xlat | --no-xlat
;
obj :=
--obj | --no-obj
;
commentOption :=
--preserve-comments | --strip-comments
;
capabilities :=
( dollarIdentifiers | lowlineIdentifiers )+
;
sourceFile :=
<platform dependent path/filename>
;
diagnostics :=
( --verbose | -v | --lexer-debug | --parser-debug | --print-settings |
--errant-semicolons )+
;
/* * * T e r m i n a l S y m b o l s * * */
QuotedLiteral :=
SingleQuotedString | DoubleQuotedString
;
.SingleQuotedString :=
"'" ( QuotableCharacter | '"' )* "'"
;
.DoubleQuotedString :=
'"' ( QuotableCharacter | "'" )* '"'
;
.QuotableCharacter :=
Digit | Letter | Space | NonAlphanumQuotable
;
.Digit := '0' .. '9' ;
.Letter := 'a' .. 'z' | 'A' .. 'Z' ;
.Space := 0u20 ;
.NonAlphaNumQuotable :=
'!' | '#' | '$' | '%' | '&' | '(' | ')' | '*' | '+' | ',' |
'-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' |
'[' | '\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~'
;
endg m2cli.