forked from jyoo980/TypeScript.ts
/
ebnf.txt
26 lines (22 loc) · 1.32 KB
/
ebnf.txt
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
PROGRAM ::= ‘project’ str nl (MODULE nl)? (DIR|CLASS|INTERFACE)*
MODULE ::= ‘modules’ STRLIST # should have quotes
DIR ::= ‘dir’ str nl (ind (DIR|CLASS|INTERFACE) ded)* nl
CLASS ::= ABS? ‘class’ str IMP? EXT? (nl COMMENT)? (nl FIELD)* (nl FUNC)* nl
INTERFACE ::= ‘interface’ str EXT? (nl COMMENT)? (nl FIELD)* (nl FUNC)* nl
FIELD ::= ind ‘fields’ mod? VARLIST (nl ind 'generate' gen)* ded
FUNC ::= ind ‘function ’ mod ‘async ’? 'static'? str (nl ind COMMENT)? (nl PARAM)? (nl ind 'returns' type)? ded
PARAM ::= ind ‘params ’ VARLIST ded
COMMENT ::= ind ‘comments ’ STRLIST ded
ABS ::= ‘abstract’
IMP ::= ‘implements’ str (‘,’ str)*
EXT ::= ‘extends’ str
VARLIST ::= ‘[ ’ (type str (‘,’ type str))? ‘ ]’
STRLIST ::= ‘[ ‘ str (‘,’ str)* ‘ ]’
gen ::= (‘getters’ | ‘setters’)
mod ::= (‘private’ | ‘public’| ‘protected’)
type ::= (‘number’ | ‘boolean’| ‘string’ | str) sp
str ::= [a-z|A-Z]* sp
sp ::= ‘ ’
nl ::= [\n]+
ind ::= [\t | ]+ # tab(s) or single space(s)
ded ::= [] # this is a dedent