Re: clarification on +: and -: operators

From: Steven Sharp (sharp@cadence.com)
Date: Wed May 01 2002 - 16:29:02 PDT


Precedence: bulk

>On a related note, how many tokens make up the implicit event
>controls?
>
> @* 1 or 2?
> @(*) 1 or 4? ( or maybe 3? )
>
>On one hand, a thread Paul started (Subject: amusing grammar ambiguity)
>in September 2001 discussed this issue briefly and indicated that they
>should not be considered single tokens, but also noting the complication
>with respect to the (* token.
>
>On the other hand, Stuart's book "Verilog-2001: A Guide to the New Language
>Features...", describes @* and @(*) as "special tokens" in Chapter 11.
>
>Neither the standard, nor Stuart's book shows any examples with
>whitespace/comments within either @* or @(*).

The (* problem is annoying. One way of dealing with it would be to
treat (*) as a single token in the lexer, to avoid it completely. I
doubt that was the original intent, which was probably "Use * as a
wildcard. And since people often put parentheses around their event
controls even when there is only one item in it, allow that. But
don't allow @(* or foo), just allow @(*)." I don't relish kludging
the parser to treat '(*' as the start of an attribute unless the next
token is ')', in which case it is really '*' in parens. It was a poor
choice of syntax.

I don't know that making the '@' part of the same token is necessary,
especially since it requires an extra character of lookahead in the
lexer.

Implementations could also go the other way and treat "(*)" as three
tokens. Then since there is a lexical ambiguity with the "(*" at the
start of an attribute, require spaces to disambiguate it, as in "( * )".
Note that C has situations like this where the user is required to
disambiguate things to avoid backtracking in the parser. Let me say
again, it was a poor choice of syntax. And I should have caught it
before Paul did, but some things you don't notice until you start
implementation.

Steven Sharp
sharp@cadence.com



This archive was generated by hypermail 2.1.4 : Mon Jul 08 2002 - 12:55:36 PDT and
sponsored by Boyd Technology, Inc.