TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

enum RuleToSourceFlags in Tinman.Core.Parsing

[Flags]
enum RuleToSourceFlags  

Items

None = 0

No format flags for emitting source code.

Compact = 0x01

Emits compact computerish source code instead of nice-looking human-readable code.

OmitAst = 0x02

Omit AST-building rule syntax.

OmitTrim = 0x04

Omit whitespace trimming rules?

EmitExternal = 0x08

Also emit external rules in source code?

GrammarAst = 0x10

Outputs grammar rules in a way that represents the hierarchical structure of the abstract syntax tree that is created by the grammar.

Remarks:

AST rules are retained, all others are dropped (see Ast, AstIfLeft, AstIfRight). AST nodes are represented as token rules (see Token), using the AST node type as the value (see Type). The start and end of the children list of an AST node are marked with '{' and '}' token rules.

For example, the AST grammar of GrammarCode grammar looks like this:

grammar       := 'GRAMMAR' '{' (decl-skip | decl-rule)+ '}' ;

decl-rule     := 'RULE' '{' 'NAME' rule '}' | 'RULE_FLAGS' '{' 'RULE_FLAG' 'RULE' '{' 'NAME' rule '}' '}' ;
decl-skip     := 'RULE' '{' 'SKIP' rule '}' ;

rule          := rule-list ;
rule-ast      := 'EXPR_AST' '{' 'NAME' rule (('IF_LEFT' | 'IF_RIGHT') rule)? '}' ;
rule-brace    := 'EXPR_BRACE' '{' rule '}' ;
rule-choice   := rule-sequence | 'EXPR_CHOICE' '{' rule-sequence rule-sequence+ '}' ;
rule-except   := rule-not | 'EXPR_EXCEPT' '{' rule-not rule-not '}' ;
rule-list     := rule-choice | 'EXPR_LIST' '{' rule-choice rule-choice '}' ;
rule-not      := rule-primary | 'EXPR_NOT' '{' rule-primary '}' ;
rule-primary  := rule-char | rule-token | rule-name | rule-brace | rule-ast ;
rule-repeat   := rule-except | 'EXPR_REPEAT' '{' rule-except ('ZERO_OR_ONE' | 'ZERO_OR_MORE' | 'ONE_OR_MORE' | 'MIN_MAX' '{' number number? '}') '}' ;
rule-sequence := rule-trim | 'EXPR_SEQUENCE' '{' rule-trim rule-trim+ '}' ;
rule-trim     := rule-repeat | 'EXPR_TRIM_RIGHT' '{' rule-repeat '}' | 'EXPR_TRIM_LEFT' '{' (rule-repeat | 'EXPR_TRIM_RIGHT' '{' rule-repeat '}') '}' ;

rule-char     := char-range | char-set | char-set-inv | char-eof ;

char-range    := char-one | 'CHAR_RANGE' '{' char-one char-one '}' ;

char-one      := 'CHAR_ONE' '{' char-esc '}' ;
char-set      := 'CHAR_SET' '{' (char-esc | 'CHAR_ONE')+ '}' ;
char-set-inv  := 'CHAR_SET_INV' '{' (char-esc | 'CHAR_ONE')+ '}' ;
rule-token    := 'EXPR_TOKEN' '{' char-esc* '}' | 'EXPR_TOKEN_NOCASE' '{' 'EXPR_TOKEN' '{' char-esc* '}' '}' ;

char-eof      := 'CHAR_EOF' ;
char-esc      := 'CHAR_ESC' ;
number        := 'NUMBER' ;
rule-name     := 'EXPR_SUBRULE' ;

See also:

AstNode.ToStringGrammar
Optimize = 0x20

Optimize output by removing redundant grammar elements?