summaryrefslogtreecommitdiff
path: root/Source/Core/Parser.cs
diff options
context:
space:
mode:
authorGravatar Dan Liew <daniel.liew@imperial.ac.uk>2014-04-06 16:47:11 +0100
committerGravatar Dan Liew <daniel.liew@imperial.ac.uk>2014-04-06 16:47:11 +0100
commit71f8c1bb366154083ff5eff5943520d9511ea014 (patch)
tree8fd06d4dad5b36011db3ae7aa19d9fa0f4838c85 /Source/Core/Parser.cs
parent0a1ced90f52b5572d0ffef0a476a1bb4270522c2 (diff)
Added /useBaseNameForFile command line argument. The Scanner
and Parser constructors have been modified to take an optional argument specifying this and the ExecutionEngine passes for that value CommandLineOptions.Clo.UseBaseNameForFileName This option when true causes the basename of file to be used inside created Tokens instead of what the user passed on the command line which might be a relative or absolute path. The motivation for adding this option is that it is needed for the lit driven tests so that the output of Boogie can be reliably checked.
Diffstat (limited to 'Source/Core/Parser.cs')
-rw-r--r--Source/Core/Parser.cs10
1 files changed, 5 insertions, 5 deletions
diff --git a/Source/Core/Parser.cs b/Source/Core/Parser.cs
index 8049c220..2149e12c 100644
--- a/Source/Core/Parser.cs
+++ b/Source/Core/Parser.cs
@@ -49,7 +49,7 @@ readonly StructuredCmd/*!*/ dummyStructuredCmd;
///Returns the number of parsing errors encountered. If 0, "program" returns as
///the parsed program.
///</summary>
-public static int Parse (string/*!*/ filename, /*maybe null*/ List<string/*!*/> defines, out /*maybe null*/ Program program) /* throws System.IO.IOException */ {
+public static int Parse (string/*!*/ filename, /*maybe null*/ List<string/*!*/> defines, out /*maybe null*/ Program program, bool useBaseName=false) /* throws System.IO.IOException */ {
Contract.Requires(filename != null);
Contract.Requires(cce.NonNullElements(defines,true));
@@ -59,25 +59,25 @@ public static int Parse (string/*!*/ filename, /*maybe null*/ List<string/*!*/>
if (filename == "stdin.bpl") {
var s = ParserHelper.Fill(Console.In, defines);
- return Parse(s, filename, out program);
+ return Parse(s, filename, out program, useBaseName);
} else {
FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
var s = ParserHelper.Fill(stream, defines);
- var ret = Parse(s, filename, out program);
+ var ret = Parse(s, filename, out program, useBaseName);
stream.Close();
return ret;
}
}
-public static int Parse (string s, string/*!*/ filename, out /*maybe null*/ Program program) /* throws System.IO.IOException */ {
+public static int Parse (string s, string/*!*/ filename, out /*maybe null*/ Program program, bool useBaseName=false) /* throws System.IO.IOException */ {
Contract.Requires(s != null);
Contract.Requires(filename != null);
byte[]/*!*/ buffer = cce.NonNull(UTF8Encoding.Default.GetBytes(s));
MemoryStream ms = new MemoryStream(buffer,false);
Errors errors = new Errors();
- Scanner scanner = new Scanner(ms, errors, filename);
+ Scanner scanner = new Scanner(ms, errors, filename, useBaseName);
Parser parser = new Parser(scanner, errors, false);
parser.Parse();