Enhanced C#
Language of your choice: library documentation

Documentation moved to ecsharp.net

GitHub doesn't support HTTP redirects, so you'll be redirected in 3 seconds.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public static fields | Static Public Member Functions | List of all members
Loyc.LLPG.Macros Class Reference

Macros for using LLLPG in LeMP. More...


Source file:

Remarks

Macros for using LLLPG in LeMP.

Example:

class Foo {
[DefaultK(2)] LLLPG lexer
{
private rule Int @[ '0'..'9'+ ];
private rule Id @[ 'a'..'z'|'A'..'Z' ('a'..'z'|'A'..'Z'|'0'..'9'|'_')* ];
token Token @[ Int | Id ];
};
};

Up to three macros are used to invoke LLLPG.

  1. there is a macro to recognize the pattern LLLPG(lexer, {...}) and translate "lexer" to an unprintable literal of type IntStreamCodeGenHelper, and another macro for LLLPG(parser(Symbol, false), {...})"</c> that creates a <see cref="GeneralCodeGenHelper"/> (this is the default helper).</li> <li>The stage-one rule() macro uses <see cref="StageOneParser"/> to translate token trees into expressions, e.g. <c>@[ ("Foo" | bar)* ~';' ]</c> is currently translated to <c>#tuple(@`suf*`("Foo" | bar), ~';').
  2. The stage-two macro is named run_LLLPG(). It accepts the code-gen helper created by the LLLPG(lexer) or LLLPG(parser) macro, and it has the ProcessChildrenBefore flag so that the stage-1 rule() macros run first. run_LLLPG calls StageTwoParser to translate expressions into Pred objects, and then invokes LLParserGenerator to analyze the grammar and generate code.

Public static fields

static readonly Symbol MacroNamespace = GSymbol.Get("Loyc.LLPG")
 

Static Public Member Functions

static LNode LLLPG_lexer (LNode node, IMacroContext context)
 Helper macro that translates lexer in LLLPG(lexer, {...}) into a IntStreamCodeGenHelper object. More...
 
static LNode LLLPG_parser (LNode node, IMacroContext context)
 Helper macro that translates parser in LLLPG(parser, {...}) into a GeneralCodeGenHelper object. More...
 
static LNode rule (LNode node, IMacroContext context)
 
static LNode ECSharpRule (LNode node, IMacroContext context)
 
static LNode LLLPG_stage1 (LNode node, IMessageSink sink)
 
static LNode run_LLLPG (LNode node, IMacroContext context)
 

Member Function Documentation

static LNode Loyc.LLPG.Macros.LLLPG_lexer ( LNode  node,
IMacroContext  context 
)
inlinestatic

Helper macro that translates lexer in LLLPG(lexer, {...}) into a IntStreamCodeGenHelper object.

References LeMP.MacroContext.GetOptions().

static LNode Loyc.LLPG.Macros.LLLPG_parser ( LNode  node,
IMacroContext  context 
)
inlinestatic

Helper macro that translates parser in LLLPG(parser, {...}) into a GeneralCodeGenHelper object.

References Loyc.Syntax.LNode.Args, LeMP.MacroContext.GetOptions(), Loyc.Syntax.LNode.Value, and Loyc.IMessageSink.Write().