From 71f8c1bb366154083ff5eff5943520d9511ea014 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Sun, 6 Apr 2014 16:47:11 +0100 Subject: 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. --- Source/Core/Parser.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Source/Core/Parser.cs') 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. /// -public static int Parse (string/*!*/ filename, /*maybe null*/ List defines, out /*maybe null*/ Program program) /* throws System.IO.IOException */ { +public static int Parse (string/*!*/ filename, /*maybe null*/ List 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 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(); -- cgit v1.2.3