Example #1
0
        private void findTimesChar(ParsingContext context, CustomParserAction customAction)
        {
            string currentStr = context.CurrentParserInput.Term.Name;

            Debug.WriteLine("findTimesChar: current Term = " + currentStr);

            if (context.CurrentParserInput.Term == base.Eof)
            {
                return;
            }
            var          scanner = context.Parser.Scanner;
            ParserAction action;

            scanner.BeginPreview();
            Token preview = scanner.GetToken();

            scanner.EndPreview(true);

            string previewStr = preview.Terminal.Name;

            Debug.WriteLine("findTimesChar: preview Term = " + previewStr);
            if (currentStr.Equals("NUMBER") && previewStr.Equals("TIMES"))
            {
                action = customAction.ReduceActions.First();
            }
            else
            {
                action = customAction.ShiftActions.First(a => a.Term.Name == "NUMBER");
            }
            action.Execute(context);
        }
Example #2
0
        public override void Apply(LanguageData language, LRItem owner)
        {
            //Create custom action and put it into state.Actions table
            var state  = owner.State;
            var action = new CustomParserAction(language, state, _executeMethod);

            _previewMethod?.Invoke(action);
            if (!state.BuilderData.IsInadequate)
            {
                // adequate state, with a single possible action which is DefaultAction
                state.DefaultAction = action;
            }
            else if (owner.Core.Current != null)
            {
                //shift action
                state.Actions[owner.Core.Current] = action;
            }
            else
            {
                foreach (var lkh in owner.Lookaheads)
                {
                    state.Actions[lkh] = action;
                }
            }
            //We consider all conflicts handled by the action
            state.BuilderData.Conflicts.Clear();
        }
Example #3
0
 private void ResolveConflicts(ParsingContext context, CustomParserAction action)
 {
 }