diff options
Diffstat (limited to 'examples/typedlua/tlerror.lua')
-rw-r--r-- | examples/typedlua/tlerror.lua | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/examples/typedlua/tlerror.lua b/examples/typedlua/tlerror.lua new file mode 100644 index 0000000..fe3a72e --- /dev/null +++ b/examples/typedlua/tlerror.lua | |||
@@ -0,0 +1,47 @@ | |||
1 | |||
2 | local errors = {} | ||
3 | local function new_error (label, msg) | ||
4 | table.insert(errors, { label = label, msg = msg }) | ||
5 | end | ||
6 | |||
7 | new_error("Number", "malformed <number>") | ||
8 | new_error("String", "malformed <string>") | ||
9 | new_error("LongString", "unfinished long string") | ||
10 | new_error("LongComment", "unfinished long comment") | ||
11 | new_error("MissingCP", "missing ')'") | ||
12 | new_error("MissingCC", "missing '}'") | ||
13 | new_error("MissingCB", "missing ']'") | ||
14 | new_error("UnionType", "expecting <type> after '|'") | ||
15 | new_error("FunctionType", "expecting <type> after '->'") | ||
16 | new_error("MethodType", "expecting <type> after '=>'") | ||
17 | new_error("TupleType", "expecting <type> after ','") | ||
18 | new_error("Type", "expecting <type> after ':'") | ||
19 | new_error("TypeDecEnd", "missing 'end' in type declaration") | ||
20 | new_error("TypeAliasName", "expecting <name> after 'typealias'") | ||
21 | new_error("MissingEqTypeAlias", "missing '=' in 'typealias'") | ||
22 | new_error("DotIndex", "expecting <name> after '.'") | ||
23 | new_error("MethodName", "expecting <name> after ':'") | ||
24 | new_error("Then", "missing 'then'") | ||
25 | new_error("IfEnd", "missing 'end' to close if statement") | ||
26 | new_error("WhileDo", "missing 'do' in while statement") | ||
27 | new_error("WhileEnd", "missing 'end' to close while statement") | ||
28 | new_error("BlockEnd", "missing 'end' to close block") | ||
29 | new_error("ForDo", "missing 'do' in for statement") | ||
30 | new_error("ForEnd", "missing 'end' to close for statement") | ||
31 | new_error("Until", "missing 'until' in repeat statement") | ||
32 | new_error("FuncEnd", "missing 'end' to close function declaration") | ||
33 | new_error("ParList", "expecting '...'") | ||
34 | new_error("MethodCall", "expecting '(' for method call") | ||
35 | new_error("Label1", "expecting <name> after '::'") | ||
36 | new_error("Label2", "expecting '::' to close label declaration") | ||
37 | new_error("LocalAssign", "expecting expression list after '='") | ||
38 | |||
39 | local labels = {} | ||
40 | for k, v in ipairs(errors) do | ||
41 | labels[v.label] = k | ||
42 | end | ||
43 | |||
44 | return { | ||
45 | errors = errors, | ||
46 | labels = labels, | ||
47 | } | ||