[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Two questions for scanning/parsing, IDENT vs. TYPE, operators
Hi,
(I)
I would like to be able to let the scanner descide if a recognized token
is simply a IDENT or a TYPE.
The scanner could simply lookup this in a symbol table.
Thus I would like to have a SymbolTable, which is shared between
scanner and parser.
Now I would need the ability to perform actions during parsing, e.g.
placing an ident into the symboltable thus letting the scanner know,
that I would like to get a TYPE token the next time this ident is
scanned.
How do I define my own token classes and let the parser and scanner
interact in this way?
(II)
Very similar: I would like to have user defined operators.
This are not only the standard operators like in C++ or in JAVA.
E.G. the user should be able to do this (in C++ style):
Result operator ** (Number lhs, Number rhs); // XX
This means I want to be able to tell the scanner that in some
circumstances ** is a operator. E.G: a USEROP or so, as I do not know
what kind of operators the USER will define in its program I want
to have an action which tells the scanner that now an operator
like that above in // XX is available. Later I want to remove this
operator eventually.
Summary:
Thinking I have several token categories:
IDENTS
OPERATORS
KEYWORDS
SEPERATORS
BRACKETS
I would like to be able to extend each of them during parsing.
I would like to get back from the scanner IDENT(String),
BRACKET('(') or BRACKET ('{') or OPERATOR('**') etc.
Thanx for your help.
Angelo
---------------------------------------------------------------------
Angelo Schneider OOAD/UML Angelo.Schneider@xcc.de
Putlitzstr. 24 Patterns/FrameWorks Fon: +49 721 9812465
76137 Karlsruhe C++/JAVA Fax: +49 721 9812467