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
Namespaces | Classes | Typedefs | Enumerations | Functions
Package LeMP

The lexical macro processor. Main classes: LeMP.Compiler and LeMP.MacroProcessor. More...

Namespaces

package  Prelude
 Defines prelude macros, which are predefined macros that normally do not have to be explicitly imported before use (in LES or EC#).
 
package  Test
 

Classes

class  Compiler
 A class that helps you invoke MacroProcessor on on a set of source files, given a set of command-line options. More...
 
class  ContainsMacrosAttribute
 Marks a class to be searched for macros. More...
 
interface  IMacroContext
 This interface provides services offered by the lexical macro processor (LeMP). More...
 
class  InputOutput
 For LeMP: an input file plus per-file options (input and output language) and output code. More...
 
class  LexicalMacroAttribute
 Marks a method as an LEL simple macro. More...
 
class  MacroContext
 Standard extension methods for IMacroContext. More...
 
class  MacroInfo
 Data returned from IMacroContext.AllKnownMacros More...
 
class  MacroProcessor
 Encapsulates the LeMP engine, a simple LISP-style macro processor, suitable for running LLLPG and other lexical macros. More...
 
class  MacroProcessorTests
 
class  StandardMacroTests
 
class  TestCompiler
 A simple version of Compiler that takes a single input and produces a StringBuilder. Pre-opens LeMP.Prelude namespace. More...
 

Typedefs

using S = CodeSymbols
 

Enumerations

enum  MacroMode {
  MacroMode.Normal = 0, MacroMode.NoReprocessing = 1, MacroMode.ProcessChildrenAfter = 2,
  MacroMode.ProcessChildrenBefore = 4, MacroMode.Passive = 8, MacroMode.AllowDuplicates = 16,
  MacroMode.DropRemainingListItems = 32, MacroMode.PriorityFallbackMin = 0x100, MacroMode.PriorityFallback = 0x300,
  MacroMode.PriorityInternalFallback = 0x400, MacroMode.PriorityNormal = 0x500, MacroMode.PriorityInternalOverride = 0x600,
  MacroMode.PriorityOverride = 0x700, MacroMode.PriorityOverrideMax = 0x900, MacroMode.PriorityMask = 0xF00
}
 Flags that affect the way that LeMP.MacroProcessor uses a SimpleMacro. Unless otherwise specified, these flags only apply when the macro accepts the input by returning a non-null result. More...
 

Functions

delegate LNode LexicalMacro (LNode node, IMacroContext context)
 Method signature of an LeMP macro. More...
 

Detailed Description

The lexical macro processor. Main classes: LeMP.Compiler and LeMP.MacroProcessor.

Enumeration Type Documentation

Flags that affect the way that LeMP.MacroProcessor uses a SimpleMacro. Unless otherwise specified, these flags only apply when the macro accepts the input by returning a non-null result.

Enumerator
Normal 

The macro's result is reprocessed directly (this is the default behavior).

NoReprocessing 

The macro's result (including children) is not processed further.

ProcessChildrenAfter 

The macro's result is not reprocessed, but the result's children are processed.

ProcessChildrenBefore 

The result is pre-processed before calling the macro, and not processed afterward.

Passive 

It is normal for this macro not to change the code, so a warning should not be printed when the macro "rejects" the input by returning null.

AllowDuplicates 

If this macro is ambiguous with one or more macro of the same priority, this flag blocks the ambiguity error message if all the macros produce the same results.

DropRemainingListItems 

If this macro succeeds, all nodes after this one in the current attribute or statement/argument list are dropped.

Tyically this option is used by macros that splice together the list of IMacroContext.RemainingNodes into their own result.

PriorityFallbackMin 

Lowest priority. If this macro is ambiguous with another macro that doesn't have this flag, the results produced by the other macro are used (note: only one priority flag can be used at a time).

PriorityFallback 

Low priority. If this macro is ambiguous with another macro that doesn't have this flag nor FallbackMin, the results produced by the other macro are used (note: only one priority flag can be used at a time).

PriorityInternalFallback 

Used to order behavior of standard macros.

PriorityNormal 

Normal priority (this is the default and does not need to be specified.)

PriorityInternalOverride 

Used to order behavior of standard macros.

PriorityOverride 

High priority. If this macro is ambiguous with another macro that doesn't have this flag nor OverrideAll, this macro takes precedence (note: only one priority flag can be used at a time).

PriorityOverrideMax 

Highest priority. If this macro is ambiguous with another macro that doesn't have this flag, the results produced by this macro are used (note: only one priority flag can be used at a time).

PriorityMask 

For internal use to isolate the priority of a macro.

Function Documentation

delegate LNode LeMP.LexicalMacro ( LNode  node,
IMacroContext  context 
)

Method signature of an LeMP macro.

Parameters
nodeThe node that caused the macro to be invoked (includes the name of the macro itself, and any attributes applied to the macro)
contextThis is a dual-purpose object. Firstly, this object implements IMessageSink. if the input does not have a valid form, the macro rejects it by returning null. Before returning null, the macro should explain the reason for the rejection (including a pattern that the macro accepts) by writinga message to this object. Secondly, this object contains additional information including the ancestors of the current node and a list of "scoped properties" (see IMacroContext.)
Returns
A node to replace the original node, or null if this macro rejects the input node. Returning null can allow a different macro to accept the node instead.

If there are multiple macros in scope with the same name, they are all called. Macro expansion succeeds if exactly one macro accepts the input. If no macros accept the input, the error message given by each macro is printed; if multiple macros accept the input, an ambiguity error is printed.

When the macro processor scans an assembly looking for macros, it requires ContainsMacrosAttribute on the containing class, and LexicalMacroAttribute on each macro in the class. The macros must be public static methods.