The present invention provides a method and apparatus for the lexical analysis
of computer source code. The lexical analyzer is dynamically configured at runtime
to recognize a one or more reserved words or operators. Thus, the analyzer has
the ability to interact with multiple languages. In one or more embodiments of
the present invention, the analyzer is instantiated by a host application, for
example, the parser of a compiler. The host application adds a list of tokens to
the analyzer that must be recognized. These tokens comprise at least a subset of
the reserved words and operators of the computer language. In one embodiment, the
host application then queries the analyzer for the next token in the source code.
In another embodiment, tokens are added during the query phase as needed. In a
separate embodiment, tokens are dynamically removed from the analyzer as the needs
of the host application change.