fr.umlv.tatoo.runtime.tools.builder
Class Builder

java.lang.Object
  extended by fr.umlv.tatoo.runtime.tools.builder.Builder

public class Builder
extends Object

This class allows to easily create lexer, parser and analyzer (lexer+parser) using a fluent API.

  1. Lexer
  • Parser
    1. Create a simple parser (with no lexer):
        Builder.parser(parserTable).
          listener(parserListener).
          create();
        
    2. Create a simple parser with a start non terminal and a version:
        Builder.parser(parserTable).
          listener(parserListener).
          start(startNonTerminal).
          version(version).
          create();
        
    3. Create a simple parser with a specific error policy:
        ParserErrorRecoveryPolicy<...> errorPolicy=...
        Builder.parser(parserTable).
          listener(parserListener).
          expert().
          errorPolicy(errorPolicy).
          create();
        
  • Analyzer
    1. Create a simple analyzer:
        Builder.analyzer(lexerTable,parserTable,toolsTable).
          reader(reader).
          listener(analyzerListener).
          create();
        
    2. Create a simple analyzer with a tools listener:
        ToolsListener<...> toolsListener=...
        Builder.analyzer(lexerTable,parserTable,toolsTable).
          reader(reader).
          listener(toolsListener).
          create();
        
    Note that the class Analyzer generated by Tatoo tools has builder methods that provide already configured lexer, parser or analyzer builder with data tables and/or evaluators.

    Author:
    Remi

    Nested Class Summary
    static class Builder.AnalyzerBufferBuilder<R,B extends LexerBuffer,T,N,P,V>
               
    static class Builder.AnalyzerBuilder<R,B extends LexerBuffer,T,N,P,V>
               
    static class Builder.AnalyzerFromParserBuilder<R,B extends LexerBuffer,T,N,P,V>
               
    static class Builder.AnalyzerTableBuilder<R,T,N,P,V>
               
    static class Builder.BranchAnalyzerBuilder<R,B extends LexerBuffer,T,N,P,V>
               
    static class Builder.ExpertAnalyzerBuilder<R,B extends LexerBuffer,T,N,P,V>
               
    static class Builder.ExpertLexerBuilder<R,B extends LexerBuffer>
              A lexer builder that configures the error policy and lifecycle handler of the lexer.
    static class Builder.ExpertParserBuilder<T,N,P,V>
               
    static class Builder.LexerBufferBuilder<R,B extends LexerBuffer>
              A lexer builder that configure the listener of the lexer.
    static class Builder.LexerBuilder<R,B extends LexerBuffer>
              A lexer builder that is able to set an activator, create a lexer or create a new builder in expert mode.
    static class Builder.LexerTableBuilder<R>
              A lexer builder that configures the buffer of the lexer.
    static class Builder.ParserBuilder<T,N,P,V>
              A parser builder able to configure the version of the grammar and the start non terminal that will be used by the parser.
    static class Builder.ParserTableBuilder<T,N,P,V>
              Parser builder that is able to configure a parser listener.
     
    Method Summary
    static
    <R,T,N,P,V>
    Builder.AnalyzerTableBuilder<R,T,N,P,V>
    analyzer(LexerTable<R> lexerTable, ParserTable<T,N,P,V> parserTable, ToolsTable<R,T> toolsTable)
               
    static
    <R> Builder.LexerTableBuilder<R>
    lexer(LexerTable<R> lexerTable)
              Creates a lexer builder from a lexer table.
    static
    <T,N,P,V> Builder.ParserTableBuilder<T,N,P,V>
    parser(ParserTable<T,N,P,V> parserTable)
              Creates a parser builder from a parser table.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Method Detail

    lexer

    public static <R> Builder.LexerTableBuilder<R> lexer(LexerTable<R> lexerTable)
    Creates a lexer builder from a lexer table.

    Type Parameters:
    R - type of the rules.
    Parameters:
    lexerTable - a lexer table
    Returns:
    a lexer builder configured with the lexer table.
    Throws:
    IllegalArgumentException - if the lexerTable is null.

    parser

    public static <T,N,P,V> Builder.ParserTableBuilder<T,N,P,V> parser(ParserTable<T,N,P,V> parserTable)
    Creates a parser builder from a parser table.

    Type Parameters:
    T - type of terminals.
    N - type of non-terminals.
    P - type of productions.
    V - type of versions.
    Parameters:
    parserTable - a parser table.
    Returns:
    a parser builder configured with the parser table
    Throws:
    IllegalArgumentException - if the lexerTable is null.

    analyzer

    public static <R,T,N,P,V> Builder.AnalyzerTableBuilder<R,T,N,P,V> analyzer(LexerTable<R> lexerTable,
                                                                               ParserTable<T,N,P,V> parserTable,
                                                                               ToolsTable<R,T> toolsTable)