pub struct SyntaxDirectedTranslator<LexemeType: Handled, Context, Satellite> { /* private fields */ }
Expand description
A syntax-directed translation engine based on a LALR parser.
Instances of this type are compiled parsers that’s capable of consuming Lexemes categorized
by LexemeType
, hold a translation context of type Context
, and translate subtrees of the
input syntax tree into instances of Satellite
.
See parsing and SyntaxDirectedTranslatorBuilder for more details on the parser and its specifications.
Implementations§
Source§impl<LexemeType, Context, Satellite> SyntaxDirectedTranslator<LexemeType, Context, Satellite>where
LexemeType: AutomaticallyHandled + Debug,
impl<LexemeType, Context, Satellite> SyntaxDirectedTranslator<LexemeType, Context, Satellite>where
LexemeType: AutomaticallyHandled + Debug,
Sourcepub fn translate(
&self,
context: &mut Context,
stream: impl Iterator<Item = Lexeme<LexemeType>>,
) -> Option<Satellite>
pub fn translate( &self, context: &mut Context, stream: impl Iterator<Item = Lexeme<LexemeType>>, ) -> Option<Satellite>
Parses a sequence of input lexemes.
Operating on the given translation context
, the parser consumes the streams
’s lexemes,
reconstructs their syntax tree, and translates it into an intermediate representation
(of type Satellite
) according to the user-defined translation scheme specified when the
parser was built.
Returns the translated syntax tree, or None if a syntactic error was found.