-
Notifications
You must be signed in to change notification settings - Fork 6
/
grammar.d.ts
121 lines (113 loc) · 4.86 KB
/
grammar.d.ts
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
declare interface IExternals {
concatenating_space: ($: IExternals) => any;
_if_else_separator: ($: IExternals) => any;
_no_space: ($: IExternals) => any;
_func_call: ($: IExternals) => any;
}
declare interface IRules {
program: ($: IRules & IExternals) => any;
rule: ($: IRules & IExternals) => any;
pattern: ($: IRules & IExternals) => any;
range_pattern: ($: IRules & IExternals) => any;
_special_pattern: ($: IRules & IExternals) => any;
directive: ($: IRules & IExternals) => any;
_statement: ($: IRules & IExternals) => any;
_statement_separated: ($: IRules & IExternals) => any;
_control_statement: ($: IRules & IExternals) => any;
if_statement: ($: IRules & IExternals) => any;
else_clause: ($: IRules & IExternals) => any;
while_statement: ($: IRules & IExternals) => any;
do_while_statement: ($: IRules & IExternals) => any;
for_statement: ($: IRules & IExternals) => any;
for_in_statement: ($: IRules & IExternals) => any;
break_statement: ($: IRules & IExternals) => any;
continue_statement: ($: IRules & IExternals) => any;
delete_statement: ($: IRules & IExternals) => any;
exit_statement: ($: IRules & IExternals) => any;
return_statement: ($: IRules & IExternals) => any;
switch_statement: ($: IRules & IExternals) => any;
switch_body: ($: IRules & IExternals) => any;
switch_case: ($: IRules & IExternals) => any;
switch_default: ($: IRules & IExternals) => any;
_io_statement: ($: IRules & IExternals) => any;
_getline_exp: ($: IRules & IExternals) => any;
getline_input: ($: IRules & IExternals) => any;
getline_file: ($: IRules & IExternals) => any;
next_statement: ($: IRules & IExternals) => any;
nextfile_statement: ($: IRules & IExternals) => any;
_print_args: ($: IRules & IExternals) => any;
print_statement: ($: IRules & IExternals) => any;
printf_statement: ($: IRules & IExternals) => any;
redirected_io_statement: ($: IRules & IExternals) => any;
piped_io_statement: ($: IRules & IExternals) => any;
block: ($: IRules & IExternals) => any;
_block_content: ($: IRules & IExternals) => any;
_exp: ($: IRules & IExternals) => any;
ternary_exp: ($: IRules & IExternals) => any;
binary_exp: ($: IRules & IExternals) => any;
_binary_in: ($: IRules & IExternals) => any;
unary_exp: ($: IRules & IExternals) => any;
update_exp: ($: IRules & IExternals) => any;
assignment_exp: ($: IRules & IExternals) => any;
piped_io_exp: ($: IRules & IExternals) => any;
string_concat: ($: IRules & IExternals) => any;
field_ref: ($: IRules & IExternals) => any;
array_ref: ($: IRules & IExternals) => any;
exp_list: ($: IRules & IExternals) => any;
regex: ($: IRules & IExternals) => any;
_regex_char: ($: IRules & IExternals) => any;
_regex_char_escaped: ($: IRules & IExternals) => any;
_regex_char_class: ($: IRules & IExternals) => any;
_regex_bracket_exp: ($: IRules & IExternals) => any;
regex_pattern: ($: IRules & IExternals) => any;
regex_flags: ($: IRules & IExternals) => any;
regex_constant: ($: IRules & IExternals) => any;
grouping: ($: IRules & IExternals) => any;
_primitive: ($: IRules & IExternals) => any;
identifier: ($: IRules & IExternals) => any;
namespace: ($: IRules & IExternals) => any;
ns_qualified_name: ($: IRules & IExternals) => any;
number: ($: IRules & IExternals) => any;
string: ($: IRules & IExternals) => any;
escape_sequence: ($: IRules & IExternals) => any;
func_def: ($: IRules & IExternals) => any;
param_list: ($: IRules & IExternals) => any;
func_call: ($: IRules & IExternals) => any;
_builtin_func_call: ($: IRules & IExternals) => any;
indirect_func_call: ($: IRules & IExternals) => any;
args: ($: IRules & IExternals) => any;
comment: ($: IRules & IExternals) => any;
}
declare interface IGrammar {
name: string;
extras?: ($: IRules & IExternals) => any;
inline?: ($: IRules & IExternals) => any;
conflicts?: ($: IRules & IExternals) => any;
externals?: ($: IExternals) => any;
word?: ($: IRules & IExternals) => any;
supertypes?: ($: IRules & IExternals) => any;
precedences?: ($: IRules & IExternals) => any;
rules: IRules;
}
declare function grammar(g: IGrammar): any;
declare type TRule = (($: IRules & IExternals) => any) | string | RegExp;
declare interface IPrecFunc {
(rule: TRule): TRule;
(val: number | string, rule: TRule): TRule;
}
declare interface ITokenFunc {
(rule: TRule): TRule;
}
declare function seq(...rules: TRule[]): TRule;
declare function choice(...rules: TRule[]): TRule;
declare function repeat(rule: TRule): TRule;
declare function repeat1(rule: TRule): TRule;
declare function optional(rule: TRule): TRule;
declare function alias(rule: TRule, name: TRule): TRule;
declare function field(name: string, rule: TRule): TRule;
declare const prec: IPrecFunc & {
left: IPrecFunc;
right: IPrecFunc;
dynamic: (val: number, rule: TRule) => TRule;
};
declare const token: ITokenFunc & { immediate: ITokenFunc }