-
Notifications
You must be signed in to change notification settings - Fork 1
/
syntaxRuleset.ts
44 lines (37 loc) · 1.47 KB
/
syntaxRuleset.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
// ##################################################################### //
// ########################### syntaxRuleset ########################### //
// ##################################################################### //
// IMPORT THIS INTERFACE FROM the file /ts/TinyComp.ts
export default interface SyntaxRuleset {
[syntaxRuleName: string]: {
[syntaxRuleType: string]: string[];
};
}
// ====================================================== //
// ======================= Example ====================== //
// ====================================================== //
const exampleSyntaxRuleset: SyntaxRuleset = {
PRINT_FUNCTION: {
// the definition of a syntax rule consists of one or more production rules
// syntax: typeName: ["terminalSymbol1", "NON_TERMINAL_SYMBOL", ...]
// a production rule consists of one or more syntax symbols (terminal or NON_TERMINAL)
// use quantifiers at the END of a production rule to specify how many times a certain symbol can occur in a syntax rule
// supported quantifiers:
// - "?" = zero or one
// - "*" = zero or more
// - "+" = one or more
_: [
"printFunctionName",
"parameterStart",
"parameter",
"EXTRA_PARAMETER?", // optional parameter, indicated by the ? quantifier.
"parameterEnd",
],
//... more production rules go here
},
EXTRA_PARAMETER: {
_: ["parameterSeperator", "parameter"],
},
// more syntax rules go here
};
export { exampleSyntaxRuleset };