It all depends on the structure of the compiler.
On 16/05/2013, at 8:30 PM, Anthony Ramine wrote:
> Hello Richard,
>
> To silence the undefined error, the parser would need to be able to know it indeed gave up on it; that is not so straightforward.
>
> For the syntax error to be more useful, that also would require either heavy yecc surgery or rewritting erl_parse to be an handwritten descent-recursive parser --that is a thing I've always wanted to do.
For example, I have an AWK->Java compiler written in C++ as an exercise;
it needs some work on the symbol table and the runtime needs finishing,
but then it will be open-sourced.
There are three phases, not entirely unlike Erlang.
(1) Lexical analysis builds a sequence of token records in memory.
(2) Parsing recycles those tokens into an AST, resolves variables,
and does some very crude type inference.
(3) Code generation emits Java.
If a lexical error occurs, no parsing is done.
And brackets are checked during lexical analysis:
the lexical analyser only needs to keep a simple stack
of what brackets are open.
Cheers,
DBM
> -----Original Message-----
> From: Anthony Ramine [mailto:n.o...@gmail.com]
> Sent: Tuesday, May 21, 2013 15:52
> To: David Mercer
> Cc: o...@cs.otago.ac.nz; 'Siraaj Khandkar'; 'Erlang-Questions Questions'
> Subject: Re: [erlang-questions] Better error messages would be helpful
>