Esempio n. 1
0
	void StructuredCmd(out StructuredCmd/*!*/ ec) {
		Contract.Ensures(Contract.ValueAtReturn(out ec) != null); ec = dummyStructuredCmd;  Contract.Assume(cce.IsPeerConsistent(ec));
		IfCmd/*!*/ ifcmd;  WhileCmd/*!*/ wcmd;  BreakCmd/*!*/ bcmd;
		
		if (la.kind == 41) {
			IfCmd(out ifcmd);
			ec = ifcmd; 
		} else if (la.kind == 43) {
			WhileCmd(out wcmd);
			ec = wcmd; 
		} else if (la.kind == 46) {
			BreakCmd(out bcmd);
			ec = bcmd; 
		} else SynErr(107);
	}
Esempio n. 2
0
public Parser(Scanner/*!*/ scanner, Errors/*!*/ errors, bool disambiguation)
 : this(scanner, errors)
{
  // initialize readonly fields
  Pgm = new Program();
  dummyExpr = new LiteralExpr(Token.NoToken, false);
  dummyCmd = new AssumeCmd(Token.NoToken, dummyExpr);
  dummyBlock = new Block(Token.NoToken, "dummyBlock", new List<Cmd>(), new ReturnCmd(Token.NoToken));
  dummyType = new BasicType(Token.NoToken, SimpleType.Bool);
  dummyExprSeq = new List<Expr> ();
  dummyTransferCmd = new ReturnCmd(Token.NoToken);
  dummyStructuredCmd = new BreakCmd(Token.NoToken, null);
}
Esempio n. 3
0
 private static Bpl.StmtList BuildStmtList(Bpl.StructuredCmd cmd)
 {
     Bpl.StmtListBuilder builder = new Bpl.StmtListBuilder();
     builder.Add(cmd);
     return(builder.Collect(cmd.tok));
 }
Esempio n. 4
0
 public BigBlock(IToken tok, string labelName, [Captured] List<Cmd> simpleCmds, StructuredCmd ec, TransferCmd tc)
 {
     Contract.Requires(simpleCmds != null);
       Contract.Requires(tok != null);
       Contract.Requires(ec == null || tc == null);
       this.tok = tok;
       this.LabelName = labelName;
       this.Anonymous = labelName == null;
       this.simpleCmds = simpleCmds;
       this.ec = ec;
       this.tc = tc;
 }
Esempio n. 5
0
 private void ComputeAllLabels(StructuredCmd cmd)
 {
     if (cmd == null) return;
       if (cmd is IfCmd) {
     IfCmd ifCmd = (IfCmd)cmd;
     ComputeAllLabels(ifCmd.thn);
     ComputeAllLabels(ifCmd.elseIf);
     ComputeAllLabels(ifCmd.elseBlock);
       }
       else if (cmd is WhileCmd) {
     WhileCmd whileCmd = (WhileCmd)cmd;
     ComputeAllLabels(whileCmd.Body);
       }
 }
Esempio n. 6
0
 void Dump(StructuredCmd scmd, TransferCmd tcmd)
 {
     Contract.Requires(scmd == null || tcmd == null);
       Contract.Ensures(label == null && simpleCmds == null);
       if (label == null && simpleCmds == null && scmd == null && tcmd == null) {
     // nothing to do
       } else {
     if (simpleCmds == null) {
       simpleCmds = new List<Cmd>();
     }
     bigBlocks.Add(new BigBlock(Token.NoToken, label, simpleCmds, scmd, tcmd));
     label = null;
     simpleCmds = null;
       }
 }
Esempio n. 7
0
 public void Add(StructuredCmd scmd)
 {
     Contract.Requires(scmd != null);
       Dump(scmd, null);
 }