comptime-ll1-parser-gen

.

A LL1 parser with compile time features

This package provide a library based on Scall1on to build LL1 parser, which syntax analysis and (most of) the parser construction can be done at compile time using macros.

The library itself does not contain compile time code, but it is designed to be used with Scala 3 macros without any issue.

emoji places:warning To use it you should put the following things in A SINGLE FILE and in an OBJECT (see example bellow), so that it can be used with macros.

  • import ll1compiletime._
  • A macro call (inlined macro call + macro definition itself) with a call to buildParsingTable with the syntax definition created in the following point
  • The syntax definition in an object exteded with the SyntayDefintion trait. See the operators

Attributes

Example:
    /* some file where parsing occures */
    val parser = SyntaxDef.parser
    parser(tokens)
    /* Syntax definition file */
    object MyParser:
        // putting in an object improve instant feedback
        /* macro inlined call */
        private inline def getPartialParsingTable = ${init}
        /* macro definition */
        private def init(using Quotes) = Expr(buildParsingTable(SyntaxDef))
        /* syntax defintion */
        object SyntaxDef extends CompileTime[Int,MyToken,MyKind] with SyntaxDefinition[MyToken,MyKind]:
            // Write syntax defintion here
            // important : INLINE
            inline def macroCall = getPartialParsingTable

Members list

Concise view