-
Notifications
You must be signed in to change notification settings - Fork 2
/
m2cli-grammar.gll
124 lines (93 loc) · 2.14 KB
/
m2cli-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
/* M2BSK -- EBNF Grammar for Modula-2 R10 Bootstrap Kernel (subset).
*
* Copyright (c) 2017 The Modula-2 Software Foundation
*
* Author & Maintainer: Benjamin Kowarsch <org.m2sf>
*
* @synopsis
*
* Modula-2 BSK is a subset of Modula-2 R10 for bootstrapping a compiler.
*
* This document specifies the command line argument grammar in EBNF.
*
* @repository
*
* https://github.com/m2sf/m2bsk
*
* @file
*
* m2cli-grammar.gll
*
* Grammar of Modula-2 command line interface.
*
*/
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 :=
/* this should be simplified to a simple switch --foreign-identifiers */
( 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.