gnupic: Re: special numbers
Subject:
Re: special numbers
From:
Scott Dattalo ####@####.####
Date:
10 Sep 2004 06:08:53 +0100
Message-Id: <Pine.LNX.4.60.0409092121480.24919@ruckus.brouhaha.com>
On Thu, 9 Sep 2004, Craig Franklin wrote:
> The patch appears to take care of one of the problems with processor names.
> The case when the processor directive is used. There is also the case of
> using "p=<processor>" option on the list directive. I think this patch will
> break that option.
Craig,
You're right, this patch fixes the processor directive, but breaks the
list directive.
Another possibility is to introduce a lexing state to the lexer to handle
the processor directive and let this state be controlled by the parser.
The patch partially attempts this but only from within the context of the
lexer. I think it would be better for the lexer to return a PROC token
whenever it encounters the PROCESSOR directive. The parser then can call
back into the lexer and change its state to the identifier lexer state. In
addition, you'll want to do something similar in the list directive. It
will also help making the 'list' statement it's own type (i.e. instead of
making list an IDENTIFIER token, make it a LIST token which gets processed
by the 'statement:' parser rule). Then the list parameters can key right
in on the 'p=...' option and change the lexer state when this is
encountered.
FWIW, this is the way I deal with macro definitions in gpsim's command
line interface. (Yes, this is a new feature. If you haven't been
monitoring the gpsim-devel mailing list, you probably didn't know gpsim
supports command line macros now.) When a macro definition is encountered,
the parser will place the lexer into the 'macro definition' state and keep
it there until an 'endm' is encountered.
Regards,
Scott