Exemple #1
0
        public static BaseSymbol CreateLogicalAndExpression(List <BaseSymbol> expressions)
        {
            BaseSymbol symbol = null;

            if (expressions.Count == 1)
            {
                symbol = expressions.First();
            }
            else
            {
                symbol = new NonTerm(NonTermType.LogicalAndExpression, expressions);
            }
            return(symbol);
        }
Exemple #2
0
        public static BaseSymbol CreateEqualityExpression(int tokenType, List <BaseSymbol> expressions)
        {
            BaseSymbol symbol = null;

            if (expressions.Count == 1)
            {
                symbol = expressions.First();
            }
            else
            {
                NonTermType nonTermType = GrammarHelper.TokenTypeToNonTermDictionary.ContainsKey(tokenType) ?
                                          GrammarHelper.TokenTypeToNonTermDictionary[tokenType] : NonTermType.None;
                symbol = new NonTerm(nonTermType, expressions);
            }
            return(symbol);
        }
Exemple #3
0
        public static NonTerm CreateMethodCallListExpression(BaseSymbol expression, BaseSymbol id, BaseSymbol methodArguments)
        {
            NonTerm result = null;

            if ((expression is Token) && (expression as Token).Value.Equals(GrammarHelper.This))
            {
                result = CreateMethodCallListExpression(id, methodArguments);
            }
            else
            {
                List <BaseSymbol> declarations = new List <BaseSymbol>()
                {
                    expression, id, methodArguments
                };
                result = new NonTerm(NonTermType.MethodCallExpression, declarations);
            }
            return(result);
        }
Exemple #4
0
 public NonTerm(NonTerm nonTerm)
     : base(nonTerm.Value, nonTerm.Symbols)
 {
     TypeNonTerm = nonTerm.TypeNonTerm;
 }
Exemple #5
0
 public static void GetClassDecl(NonTerm nonTerm, out Token classId, out NonTerm extendsClause)
 {
     GetClassId(nonTerm, out classId);
     extendsClause = nonTerm.Symbols[1] as NonTerm;
 }
Exemple #6
0
 public static void GetClassDecl(NonTerm nonTerm, out Token classId, /*out BaseSymbol extendsClause, */ out List <BaseSymbol> declarations)
 {
     GetClassId(nonTerm, out classId);
     //extendsClause = nonTerm.Symbols[1];
     declarations = nonTerm.Symbols.Skip(2).ToList();
 }
Exemple #7
0
 public static void GetClassId(NonTerm nonTerm, out Token classId)
 {
     classId = nonTerm.Symbols[0] as Token;
 }
Exemple #8
0
 public static void GetClassVarDecl(NonTerm nonTerm, out Token typeDeclaration, out Token id)
 {
     typeDeclaration = nonTerm.Symbols[0] as Token;
     id = nonTerm.Symbols[1] as Token;
 }
Exemple #9
0
 public static void GetMethodCallExpression(NonTerm nonTerm, out Token idMethodName, out List <BaseSymbol> methodArguments)
 {
     idMethodName    = nonTerm.Symbols[0] as Token;
     methodArguments = nonTerm.Symbols[1].Symbols;
 }
Exemple #10
0
 public static void GetMainClassDecl(NonTerm nonTerm, out Token idClass, out List <BaseSymbol> statements)
 {
     idClass    = nonTerm.Symbols[0] as Token;
     statements = nonTerm.Symbols.Skip(1).ToList();
 }