summaryrefslogtreecommitdiff
path: root/Source/Core/BoogiePL.atg
diff options
context:
space:
mode:
authorGravatar Rustan Leino <leino@microsoft.com>2012-08-21 00:24:08 -0700
committerGravatar Rustan Leino <leino@microsoft.com>2012-08-21 00:24:08 -0700
commit1ac82df441e621fce2f38d53b5d17c69650d7358 (patch)
treea882d519a00f2d7cef05756598257867f7523e41 /Source/Core/BoogiePL.atg
parent61ca25219a71a22430b3f7a5071f8655cbf75cb1 (diff)
Dafny and Boogie: get rid of 'static' fields in parser
Diffstat (limited to 'Source/Core/BoogiePL.atg')
-rw-r--r--Source/Core/BoogiePL.atg58
1 files changed, 35 insertions, 23 deletions
diff --git a/Source/Core/BoogiePL.atg b/Source/Core/BoogiePL.atg
index aed741d8..9c721703 100644
--- a/Source/Core/BoogiePL.atg
+++ b/Source/Core/BoogiePL.atg
@@ -19,16 +19,15 @@ COMPILER BoogiePL
/*--------------------------------------------------------------------------*/
-static Program/*!*/ Pgm = new Program();
+readonly Program/*!*/ Pgm;
-static Expr/*!*/ dummyExpr = new LiteralExpr(Token.NoToken, false);
-static Cmd/*!*/ dummyCmd = new AssumeCmd(Token.NoToken, dummyExpr);
-static Block/*!*/ dummyBlock = new Block(Token.NoToken, "dummyBlock", new CmdSeq(),
- new ReturnCmd(Token.NoToken));
-static Bpl.Type/*!*/ dummyType = new BasicType(Token.NoToken, SimpleType.Bool);
-static Bpl.ExprSeq/*!*/ dummyExprSeq = new ExprSeq ();
-static TransferCmd/*!*/ dummyTransferCmd = new ReturnCmd(Token.NoToken);
-static StructuredCmd/*!*/ dummyStructuredCmd = new BreakCmd(Token.NoToken, null);
+readonly Expr/*!*/ dummyExpr;
+readonly Cmd/*!*/ dummyCmd;
+readonly Block/*!*/ dummyBlock;
+readonly Bpl.Type/*!*/ dummyType;
+readonly Bpl.ExprSeq/*!*/ dummyExprSeq;
+readonly TransferCmd/*!*/ dummyTransferCmd;
+readonly StructuredCmd/*!*/ dummyStructuredCmd;
///<summary>
///Returns the number of parsing errors encountered. If 0, "program" returns as
@@ -64,20 +63,33 @@ public static int Parse (string s, string/*!*/ filename, out /*maybe null*/ Prog
Errors errors = new Errors();
Scanner scanner = new Scanner(ms, errors, filename);
- Parser parser = new Parser(scanner, errors);
- Pgm = new Program(); // reset the global variable
- parser.Parse();
- if (parser.errors.count == 0)
- {
- program = Pgm;
- program.ProcessDatatypeConstructors();
- return 0;
- }
- else
- {
- program = null;
- return parser.errors.count;
- }
+ Parser parser = new Parser(scanner, errors, false);
+ parser.Parse();
+ if (parser.errors.count == 0)
+ {
+ program = parser.Pgm;
+ program.ProcessDatatypeConstructors();
+ return 0;
+ }
+ else
+ {
+ program = null;
+ return parser.errors.count;
+ }
+}
+
+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 CmdSeq(), new ReturnCmd(Token.NoToken));
+ dummyType = new BasicType(Token.NoToken, SimpleType.Bool);
+ dummyExprSeq = new ExprSeq ();
+ dummyTransferCmd = new ReturnCmd(Token.NoToken);
+ dummyStructuredCmd = new BreakCmd(Token.NoToken, null);
}
// Class to represent the bounds of a bitvector expression t[a:b].