Class PrecompilerOutputAttribute
Enables accessing the outputs of a precompiled grammar defined with PrecompilerInputAttribute. Methods with this attribute applied are called precompiler output methods, or just output methods.
[AttributeUsage(AttributeTargets.Method)]
public sealed class PrecompilerOutputAttribute : Attribute
- Inheritance
-
PrecompilerOutputAttribute
- Inherited Members
Remarks
This attribute must be applied on non-generic, static, parameterless methods that return a Grammar or a CharParser<T>. At build time, the precompiler will update the method's body to retrieve the precompiled grammar and construct the requested object.
The following return types are supported:
- Grammar
- CharParser<T>, if the corresponding method with PrecompilerInputAttribute (the precompiler input method) returns IGrammarBuilder<T>, and the grammar builder's return type can be assigned to the parser's return type.
- CharParser<T>, if the precompiler input method returns IGrammarBuilder, or the SyntaxCheck property is set to true. In this case, the parser's return type must be a reference type.
Properties
Key
A string value that is used for disambiguation if multiple methods with PrecompilerInputAttribute exist on the same type.
public string? Key { get; set; }
Property Value
- See Also
SyntaxCheck
Whether to emit a syntax-checking parser.
public bool SyntaxCheck { get; set; }
Property Value
Remarks
Setting this property is required when the precompiler input method's type implements IGrammarBuilder<T>. Otherwise, a syntax-checking parser is always emitted.