A lexer for the Bond scripting language.
More...
#include <bond/compiler/lexer.h>
A lexer for the Bond scripting language.
The Lexer tokenizes Bond source code passed in as a C-style string. Its output is a TokenCollection that can be used as input to a Parser. A single Lexer can be used to tokenize many strings of Bond source code; each invocation generates a new TokenCollection.
When writing a tool that requires a compiler front end, the interactions between the front end components, namely a Lexer, a Parser and a SemanticAnalyzer, can be managed by a FrontEnd.
- See also
- CompilerErrorBuffer, FrontEnd, Parser, TokenCollection
◆ Lexer() [1/2]
Constructs a Lexer object.
- Parameters
-
allocator | The memory allocator from which TokenCollections are allocated. |
errorBuffer | Buffer where error messages are pushed when invalid tokens are encountered. |
◆ Lexer() [2/2]
Bond::Lexer::Lexer |
( |
const Lexer & |
other | ) |
|
|
delete |
◆ GetErrorBuffer()
Returns the buffer where error messages are pushed.
◆ Lex() [1/2]
Scans the given string of Bond source and breaks it up into a sequence of Tokens.
- Parameters
-
fileName | Name to associate with the string of Bond source code, ideally the name of the file from which the code was loaded. The name will be accessible via the generated Tokens, so that other tools, such as a Parser or SemanticAnalyzer can generate meaningful error messages. The name is not copied so the given pointer must remain valid for the lifetime of the generated TokenCollection. |
text | The Bond source code text to be tokenized. The tokens contain a copy of the original source code, so the given pointer does not need to remain valid once this function returns. |
length | The number of characters in the Bond source code. Required since the source code may contain null characters and may not be null terminated. |
- Returns
- A TokenCollectionHandle, which is an owning pointer to a dynamically allocated TokenCollection. The TokenCollection is automatically destroyed when the handle is destroyed.
◆ Lex() [2/2]
Scans the given string of Bond source and breaks it up into a sequence of Tokens.
- Parameters
-
fileName | Name to associate with the string of Bond source code, ideally the name of the file from which the code was loaded. The name will be accessible via the generated Tokens, so that other tools, such as a Parser or SemanticAnalyzer can generate meaningful error messages. The name is not copied so the given pointer must remain valid for the lifetime of the generated TokenCollection. |
stream | The stream of Bond source code text to be tokenized. |
- Returns
- A TokenCollectionHandle, which is an owning pointer to a dynamically allocated TokenCollection. The TokenCollection is automatically destroyed when the handle is destroyed.
◆ operator=()
Lexer & Bond::Lexer::operator= |
( |
const Lexer & |
other | ) |
|
|
delete |
The documentation for this class was generated from the following file:
- include/bond/compiler/lexer.h