private IDeclarationList Declarations() { IDeclarationList declarations = ImplementationFactory.CreateDeclarationList(); PqlToken declarationType; while (currentToken.Type != PqlTokenType.SELECT) { switch (currentToken.Type) { case PqlTokenType.PROCEDURE: case PqlTokenType.STMTLST: case PqlTokenType.STMT: case PqlTokenType.ASSIGN: case PqlTokenType.CALL: case PqlTokenType.WHILE: case PqlTokenType.IF: case PqlTokenType.VARIABLE: case PqlTokenType.CONSTANT: case PqlTokenType.PROG_LINE: declarationType = currentToken; Eat(currentToken.Type); while (currentToken.Type != PqlTokenType.SEMI) { declarations.AddDeclaration(Declaration(declarationType)); } Eat(PqlTokenType.SEMI); break; default: throw new Exception(); } } return(declarations); }
public void LoadArgs(IProgramKnowledgeBase pkb, IDeclarationList declarations) { if (LeftRef is PqlInteger || LeftRef is PqlString) { LeftArgs = LoadSingleLeftArg(pkb); } else if (LeftRef is PqlEmptyArg) { LeftArgs = LoadLeftArgs(pkb); } else { PqlDeclaration declaration = declarations.GetDeclarationBySynonym((LeftRef as PqlSynonym).Name); LeftArgs = declaration.EntityList; LeftArgs.ListName = (LeftRef as PqlSynonym).Name; } if (RightRef is PqlInteger || RightRef is PqlString) { RightArgs = LoadSingleRightArg(pkb); } else if (RightRef is PqlEmptyArg) { RightArgs = LoadRightArgs(pkb); } else { PqlDeclaration declaration = declarations.GetDeclarationBySynonym((RightRef as PqlSynonym).Name); RightArgs = declaration.EntityList; RightArgs.ListName = (RightRef as PqlSynonym).Name; } }
private void ProcessDeclarations(IDeclarationList declarations) { foreach (PqlDeclaration declaration in declarations) { switch (declaration.DesignEntity.Type) { case PqlTokenType.PROCEDURE: declaration.EntityList = PKB.Procedures.Copy() as EntityList; break; case PqlTokenType.VARIABLE: declaration.EntityList = PKB.Variables.Copy() as EntityList; break; case PqlTokenType.CONSTANT: declaration.EntityList = PKB.Constants.Copy() as EntityList; break; default: declaration.EntityList = PKB.Statements.Copy() as EntityList; break; } } Declarations = declarations; }
public void LoadArgs(IProgramKnowledgeBase pkb, IDeclarationList declarations) { PqlDeclaration declaration = declarations.GetDeclarationBySynonym(Synonym.Name); Args = declaration.EntityList; Args.ListName = Synonym.Name; Type = declaration.DesignEntity.Type; }
public PqlSelect(IDeclarationList declarations, PqlResult result, List <PqlWith> withClauses, List <PqlSuchThat> suchThatClauses, List <PqlPatternCond> patternClauses) { Declarations = declarations; Result = result; WithClauses = withClauses; SuchThatClauses = suchThatClauses; PatternClauses = patternClauses; }
public void LoadArgs(IProgramKnowledgeBase pkb, IDeclarationList declarations) { PqlDeclaration declaration = declarations.GetDeclarationBySynonym(LeftRef.SynonymName); LeftArgs = declaration.EntityList; LeftArgs.ListName = LeftRef.SynonymName; LeftType = declaration.DesignEntity.Type; if (RightRef is PqlInteger || RightRef is PqlString) { RightArgs = LoadSingleRightArg(pkb); } else { string synonym = RightRef is PqlAttrRef ? (RightRef as PqlAttrRef).SynonymName : (RightRef as PqlSynonym).Name; declaration = declarations.GetDeclarationBySynonym(synonym); RightArgs = declaration.EntityList; RightArgs.ListName = synonym; RightType = declaration.DesignEntity.Type; } }
private PqlSelect SelectCl() { IDeclarationList declarations = Declarations(); Eat(PqlTokenType.SELECT); PqlResult result = ResultCl(); List <PqlWith> withClauses = new List <PqlWith>(); List <PqlSuchThat> suchThatClauses = new List <PqlSuchThat>(); List <PqlPatternCond> patternClauses = new List <PqlPatternCond>(); while (currentToken.Type == PqlTokenType.SUCH || currentToken.Type == PqlTokenType.WITH || currentToken.Type == PqlTokenType.PATTERN) { switch (currentToken.Type) { case PqlTokenType.SUCH: suchThatClauses.Add(SuchThatCl()); break; case PqlTokenType.WITH: withClauses.Add(WithCl()); break; case PqlTokenType.PATTERN: patternClauses.Add(PatternCl()); break; default: throw new Exception(); } } return(new PqlSelect(declarations, result, withClauses, suchThatClauses, patternClauses)); }
public PqlTupleOutput() { Declarations = ImplementationFactory.CreateDeclarationList(); }