public SequenceStructure(PlanningParser.ProgramContext context) { int count = context.program().Count; _subProgramArray = new Program[count]; Parallel.For(0, count, i => _subProgramArray[i] = CreateInstance(context.program(i))); }
private void Initial(string domainFileName, string problemFileName, string programFileName) { CUDD.InitialiseCUDD(3072, 256, 262144, 0.1); // Create a TextReader that reads from a file TextReader tr = new StreamReader(domainFileName); // create a CharStream that reads from standard input AntlrInputStream input = new AntlrInputStream(tr); // create a lexer that feeds off of input CharStream PlanningLexer lexer = new PlanningLexer(input); // create a buffer of tokens pulled from the lexer CommonTokenStream tokens = new CommonTokenStream(lexer); // create a parser that feeds off the tokens buffer PlanningParser parser = new PlanningParser(tokens); var domainContext = parser.domain();// begin parsing at init rule tr.Close(); // Create a TextReader that reads from a file tr = new StreamReader(problemFileName); // create a CharStream that reads from standard input input = new AntlrInputStream(tr); // create a lexer that feeds off of input CharStream lexer = new PlanningLexer(input); // create a buffer of tokens pulled from the lexer tokens = new CommonTokenStream(lexer); // create a parser that feeds off the tokens buffer parser = new PlanningParser(tokens); var clientProblemContext = parser.clientProblem();// begin parsing at client problem rule //Console.WriteLine(serverProblemContext.ToStringTree(parser)); tr.Close(); //Console.ReadLine(); _problem = ClientProblem.CreateInstance(domainContext, clientProblemContext); //_problem.ShowInfo(); // Create a TextReader that reads from a file tr = new StreamReader(programFileName); // create a CharStream that reads from standard input input = new AntlrInputStream(tr); // create a lexer that feeds off of input CharStream lexer = new PlanningLexer(input); // create a buffer of tokens pulled from the lexer tokens = new CommonTokenStream(lexer); // create a parser that feeds off the tokens buffer parser = new PlanningParser(tokens); _programContext = parser.program(); // begin parsing at program rule //Console.WriteLine(serverProblemContext.ToStringTree(parser)); tr.Close(); }
public static Program CreateInstance(PlanningParser.ProgramContext context) { Program result; if (context.actionSymbol() != null) { result = new Action(context); } else if (context.SEQ() != null) { result = new SequenceStructure(context); } else if (context.IF() != null) { result = new ConditionalStructure(context); } else// if (context.WHILE() != null) { result = new LoopStructure(context); } return(result); }
public ConditionalStructure(PlanningParser.ProgramContext context) { Condition = context.subjectGd(); SubProgram1 = CreateInstance(context.program(0)); SubProgram2 = context.program().Count == 2 ? CreateInstance(context.program(1)) : EmptyProgram; }
public Action(PlanningParser.ProgramContext context) { FullName = ConstContainer.GetFullName(context.actionSymbol(), context.term()); }
public LoopStructure(PlanningParser.ProgramContext context) { Condition = context.subjectGd(); SubProgram = CreateInstance(context.program(0)); }
private void Interpret(PlanningParser.ProgramContext context) { var program = Planning.HighLevelProgramExecution.Program.CreateInstance(context); Interpret(program); }