bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] use "unresolved reference" message


From: Alex Rozenman
Subject: Re: [PATCH] use "unresolved reference" message
Date: Mon, 7 Sep 2009 00:03:10 +0300

Hi Joel,


> But your gcc analogy doesn't show why "invalid reference" is the wrong
> message only when Bison has no suggestions to give.  If you dislike the
> phrase "invalid reference", then let's discuss an alternative but use it
> consistently regardless of whether Bison has suggestions.
>
We have "invalid references", "ambiguous references" and even "misleading
references", so I am not seeing any problem with consistency.


> Maybe the trouble is that you really just want to tell the user what
> symbol name Bison extracted from the reference so that he knows what Bison
> was looking for and didn't find.  Maybe that doesn't seem as necessary to
> you when Bison has suggestions.  But I think the user may then be misled
> by the inconsistency.  So, to satisfy us both, I'd be fine with:
>
>  test.y:24.36-41: invalid reference: $cond1
>  test.y:24.36-41:   symbol not found in production: cond1
>

Looks very clear.  So what about the following:

test.y:24.36-41: invalid reference: $cond1.field
test.y:24.36-41:   symbol not found in production: cond1

Should I cut the ".field" from the first line ? Seems I shouldn't. It just
passes all the possible information to user.


>  test.y:26.43-53: invalid reference: $stmt.field
>  test.y:24.36-41:   symbol not found in production: stmt
>  test.y:25.35-38:   possibly meant: $then.field, hiding $stmt.field at $4
>
It looks redundant. However, in this specific case it really adds a piece of
useful information to the output. It actually shows what symbol bison was
looking for and would compile without complains. Another possible situation
is when a symbol is invisible from mid-rule actions. In this case, it can be
suggested to extend the message to something like this:

test.y:26.43-53: invalid reference: $stmt.field
test.y:24.36-41:   symbol not found in sub-production before $3: stmt
Could you suggest more appropriate error message ?

I'll try to implement it and check more situations.

In addition, I am going to add an item to the NEWS file. I wrote the
following text, please help me to improve it:

** Symbolic References Support

  Historically, Yacc and Bison have supported positional references ($n, $$)
  to allow access to symbol values from inside of semantic actions code.

  Starting from this version, Bison can also accept symbolic references.
  When no ambiguity possible, original symbol names may be used as symbolic
  references:

    if_stmt : 'if' cond_expr 'then' then_stmt ';'
    { $if_stmt = mk_if_stmt($cond_expr, $then_stmt); }

  In more common case, explicit symbolic names may be declared:

    stmt[result] : 'if' expr[cond] 'then' stmt[then] 'else' stmt[else] ';'
    { $result = mk_if_stmt($cond, $then, $else); }

  Location information is also accessible using @name syntax. When accessing

  symbol names containing dots or dashes, an explicit bracketing ($[sym.1])
must
  be used.

  These features are experimental in this version. More user feedback will
  help to stabilize them.

(end)

-- 
Best regards,
Alex Rozenman (address@hidden).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]