[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Feature request
From: |
Gaston Gloesener |
Subject: |
Feature request |
Date: |
Thu, 1 Aug 2002 00:04:45 +0200 |
Hi,
Here is my feature proposal.
A lot of parsers generated use a whole lot of key words resulting in
something like:
%%
keyword { return KEYWORD; }
Therefor I would suggest a set of macors like:
%key(KeyWord,...) // Keyword
%lkey(KeyWord,...) // Lowercase keyword
%ukey(KeyWord,...) // Uppercase keyword
%olkey(KeyWord,...) // optional lowercase keyword
%oukey(KeyWord,...) // optional upercase keyword
Any of these keywords without arguments (example%olkey) sets the default
mode for the %key(KeyWord) macro. For example %olkey makes all subsequent
%key(KeyWord) act as if it was a %olkey. %key resets the behavior to
default.
In default mode the above lines would have generated the following (in the
order of the above lines):
KeyWord { return KEYWORD; }
keyword { return KEYWORD; }
KEYWORD { return KEYWORD; }
[Kk]ey[Ww]ord { return KEYWORD; }
K[eE][ey]W[Oo][rR][dD] { return KEYWORD; }
Additional related features:
Any action placed after the %key (with the exception of the empty ';'
action) should be included in the action statement before the automatic
generated return statement. An ection placed after an 'empty' macro
(%key,%lkey... without arguments) shoudl additionally to set the default
behavior of the %key macro also set its action as being the default action
for any of the %*key macros
%keyprefix PREFIX_ // Uses the given prefic (here PREFIX_) in front of any
keyword as token name in the return statment.
Example:
%keyprefix PREFIX_
%olkey { BEGIN CONTEXT;} // Sets default behavior of %key and the defaul
action fo all subsequent %*key macros
%key(KeyWord) { CallAFunction() ; }
generates:
[Kk]ey[Ww]ord { { BEGIN CONTEXT;} { CallAFunction(); } return
PREFIX_KEYWORD;
Note that the default action is placed prior to the "local" action and
finaly the default return
What do you think about this draft idea ?
Regards,
Gaston
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Feature request,
Gaston Gloesener <=