4 using System.Text.RegularExpressions;
8 namespace SiliconStudio.Shaders.
Grammar
14 private Func<ConflictResolutionArgs, bool> resolver;
20 this.resolver = resolver;
25 return resolver(args);
34 private bool isExpectingType;
41 this.isExpectingType = isExpectingType;
42 this.nextGrammarHint = nextGrammarHint;
45 private string[] identifierPostFix =
new string[] {
"_OUTPUT",
"OUT",
"_INPUT",
"IN",
"OUTPUT_SCENE",
"OUTPUT_SCENEENV",
"PSSceneIn" };
47 private Regex regex =
new Regex(
"(.*\r?\n)");
51 base.Init(grammarData);
52 if (nextGrammarHint != null)
53 nextGrammarHint.Init(grammarData);
58 string identifier = args.Context.PreviousToken.Text;
73 args.Scanner.BeginPreview();
77 nextToken = args.Scanner.GetToken();
79 while (nextToken.Terminal.FlagIsSet(
TermFlags.IsNonGrammar) && nextToken.Terminal != Grammar.Eof);
81 var nextTokenName = nextToken.Terminal.Name;
83 if (nextTokenName ==
"identifier" || nextTokenName ==
"integer_literal" || nextTokenName ==
"float_literal" || nextTokenName ==
"(")
85 args.Scanner.EndPreview(
true);
89 if (!result && nextGrammarHint != null)
91 result = nextGrammarHint.Match(args);
97 args.Result = ParserActionType.Reduce;
98 args.ReduceProduction = null;
116 this.skipTokens = skipTokens;
123 args.Scanner.BeginPreview();
126 bool isKeyword =
false;
133 preview = args.Scanner.GetToken();
135 while ((preview.
Terminal.
FlagIsSet(
TermFlags.IsNonGrammar) || skipTokens.Contains(preview.Terminal)) && preview.Terminal != Grammar.Eof);
137 isKeyword = preview.EditorInfo.Color == TokenColor.Keyword;
140 previewSym = preview.Terminal.Name;
141 if (previewSym ==
"<")
145 else if (previewSym ==
">" && ltCount > 0)
152 args.Scanner.EndPreview(
true);
156 if (previewSym ==
">" || isKeyword)
158 args.Result = ParserActionType.Shift;
163 args.Result = ParserActionType.Reduce;
override void Init(GrammarData grammarData)
override bool Match(ConflictResolutionArgs args)
string Text
Gets the text associated with this token.
The class provides arguments for custom conflict resolution grammar method.
GenericResolverHint(TerminalSet skipTokens)
bool FlagIsSet(TermFlags flag)
readonly ParsingContext Context
ResolveInCode(ParserActionType parserAction, Func< ConflictResolutionArgs, bool > resolver)
Terminal Terminal
Gets the terminal.
override bool Match(ConflictResolutionArgs args)
override bool Match(ConflictResolutionArgs args)
Tokens are produced by scanner and fed to parser, optionally passing through Token filters in between...
IdentifierResolverHint(bool isExpectingType, CustomGrammarHint nextGrammarHint=null)
ParseTreeNode CurrentParserInput