Exemplo n.º 1
0
        public static GrammarRuleAlternative makeSequence(List <GrammarRuleAlternative> sequenceContent)
        {
            GrammarRuleAlternative result = new GrammarRuleAlternative(EnumType.SEQUENCE);

            result.sequenceContent = sequenceContent;
            return(result);
        }
Exemplo n.º 2
0
        public static GrammarRuleAlternative makeBrace(List <GrammarRuleAlternative> braceContent)
        {
            GrammarRuleAlternative result = new GrammarRuleAlternative(EnumType.BRACE);

            result.braceContent = braceContent;
            return(result);
        }
Exemplo n.º 3
0
        public static GrammarRuleAlternative makeTerminal(ProgramTreeElementType.EnumType terminalType)
        {
            GrammarRuleAlternative result = new GrammarRuleAlternative(EnumType.TERMINAL);

            result.terminalType = terminalType;
            return(result);
        }
Exemplo n.º 4
0
        public static GrammarRuleAlternative makeVariable(uint variable)
        {
            GrammarRuleAlternative result = new GrammarRuleAlternative(EnumType.VARIABLE);

            result.variable = variable;
            return(result);
        }
Exemplo n.º 5
0
        protected void fillRules()
        {
            rules = new List <GrammarRule>();

            rules.Add(new GrammarRule(
                          GrammarRuleAlternative.makeVariable((uint)EnumVariables.S),

                          new List <GrammarRuleAlternative>()
            {
                GrammarRuleAlternative.makeBrace(new List <GrammarRuleAlternative>()
                {
                    GrammarRuleAlternative.makeVariable((uint)EnumVariables.T),
                }),

                GrammarRuleAlternative.makeBrace(new List <GrammarRuleAlternative>()
                {
                    GrammarRuleAlternative.makeVariable((uint)EnumVariables.OPA),
                    GrammarRuleAlternative.makeVariable((uint)EnumVariables.A),
                }),

                GrammarRuleAlternative.makeBrace(new List <GrammarRuleAlternative>()
                {
                    GrammarRuleAlternative.makeTerminal(ProgramTreeElementType.EnumType.REPEAT),
                    GrammarRuleAlternative.makeVariable((uint)EnumVariables.S),
                    GrammarRuleAlternative.makeVariable((uint)EnumVariables.S),
                }),
            }
                          ));

            rules.Add(new GrammarRule(
                          GrammarRuleAlternative.makeVariable((uint)EnumVariables.OPA),

                          new List <GrammarRuleAlternative>()
            {
                GrammarRuleAlternative.makeTerminal(ProgramTreeElementType.EnumType.ADD),
                GrammarRuleAlternative.makeTerminal(ProgramTreeElementType.EnumType.SUB),
                GrammarRuleAlternative.makeTerminal(ProgramTreeElementType.EnumType.MUL),
            }
                          ));

            rules.Add(new GrammarRule(
                          GrammarRuleAlternative.makeVariable((uint)EnumVariables.A),

                          new List <GrammarRuleAlternative>()
            {
                GrammarRuleAlternative.makeVariable((uint)EnumVariables.T),
                GrammarRuleAlternative.makeSequence(new List <GrammarRuleAlternative>()
                {
                    GrammarRuleAlternative.makeVariable((uint)EnumVariables.T),
                    GrammarRuleAlternative.makeVariable((uint)EnumVariables.A),
                }),
            }
                          ));

            rules.Add(new GrammarRule(
                          GrammarRuleAlternative.makeVariable((uint)EnumVariables.T),

                          new List <GrammarRuleAlternative>()
            {
                GrammarRuleAlternative.makeTerminal(ProgramTreeElementType.EnumType.A),
                GrammarRuleAlternative.makeTerminal(ProgramTreeElementType.EnumType.B),
            }
                          ));
        }
Exemplo n.º 6
0
 public GrammarRule(GrammarRuleAlternative leftSide, List <GrammarRuleAlternative> rightSideAlternatives)
 {
     this.leftSide = leftSide;
     this.rightSideAlternatives = rightSideAlternatives;
 }