-
Notifications
You must be signed in to change notification settings - Fork 35
/
ErrorMessages.lhs
95 lines (69 loc) · 2.12 KB
/
ErrorMessages.lhs
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
[[error-messages]]
= Error messages
In this tutorial, we will start looking at the error messages
generated by Parsec and how we can influence to improve them.
TODO:
review the different methods of generating failure in parsec and what
they look like, including choice.
examine how rearranging parsers can change the error messages,
committing to a parsing branch to improve the messages
also possibly look at adding additional parsing to detect common
errors to provide a nicer error messages
maybe talk about the idea of being permissive in the parsing proper
stage, then doing additional syntax-type checks on the ast after
== ways of generating errors in parsec
== how parsec combines errors or drops them into the void
== Parsing tpch
Let's try the parser out on the TPC-H queries.
```
```
Summary of errors so far:
q1: typed literal: type_name 'literal value'
q2: scalar subquery
q3: typed literal
q4: typed literal
q5: typed literal
q6: typed literal
q7: ??
q8: extract??
q9: extract ??
q10: typed literal
q11: scalar sub query
q12: ??
q13: not like??
q14: decimal literal
q15: cte
q16: count distinct
q17: decimal literal
q18: in subquery
q19: in literal list
q20: in subquery
q21: exists subquery
q22: substring
TODO: try to figure out each issue. Not very easy: the error messages
are not very good.
Do some ad hoc stuff to try to improve each error message? Keep
simplifying expressions then try to understand specific principles.
Then make some generalizations that can be made across the parser
== value expressions in isolation
We can start with the real error code now by considering the
valueexpression parser in isolation.
ideas:
error inside function parameter list
bad identifier
unrecognised operator
unrecognised chars
unmatching parens
keyword errors in case
unterminated string lit
3 dot components
binary op with missing second arg
associativity errors with binary ops?
blacklist errors
== query expressions
mispelling keywords at this level
clauses in wrong order
adding extra tokens or removing them at clause/value expression
boundaries
== summarizing?
== updated parsing code with improved error message behaviour