Commit 8de600eb authored by Jeff Smits's avatar Jeff Smits

Fixed test, ImportTerm and SSL_fopen behaviour

parent 41896d34
......@@ -242,7 +242,7 @@ impl<'a> Eval<'a> for preprocess::Strategy {
let fd = ssl::fopen(context,
Vec::new(),
vec![context.factory.string(modname.clone()),
context.factory.list(iter::empty())],
context.factory.string(String::new())],
current)?;
ssl::read_term_from_stream(context, Vec::new(), vec![fd.clone()], fd)
}
......
......@@ -75,7 +75,7 @@ fn main() {
Err(TracedError(Error::StrategyFailed,_)) => { process::exit(1) },
Err(TracedError(e,st)) => {
println!("Stacktrace:\n{}", st);
println!("{}", e);
println!("{:?}", e);
process::exit(1)
},
Ok(result) => { println!("{}", result); process::exit(0) },
......
......@@ -621,16 +621,19 @@ pub fn fopen<'a>(context: &MutContext<'a>,
}
let file_name: String = targs[0].get_string().ok_or(Error::StrategyFailed)?;
let mut ssl_state = context.ssl_state.borrow_mut();
let path = ssl_state.sys.cwd_with_file_name(&file_name);
let path = ssl_state.sys.cwd_join(&file_name);
let mode = targs[1].get_string().ok_or(Error::StrategyFailed)?;
let append = mode.contains('a');
let write = mode.contains('w');
if !path.exists() && !(write || append) {
let _ = File::create(&path)?;
}
let file = OpenOptions::new()
.read(true)
.write(write)
.append(append)
.truncate(!append)
.create(true)
.truncate(write && !append)
.create(write || append)
.open(path)
.map_err(|_| Error::StrategyFailed)?;
let fd = ssl_state.sys.add_file(file);
......
Specification([Signature([Constructors([ExtOpDecl("Nil",ConstType(Sort("List",[SortVar("a")])))])]),Strategies([SDefT("main_0_0",[],[],Seq(ImportTerm("./Java-15.tbl"),Seq(Match(Anno(Explode(Anno(Str("parse-table"),Wld),Wld),Wld)),Build(Anno(Str("ok"),Op("Nil",[]))))))])])
\ No newline at end of file
Specification([Signature([Constructors([ExtOpDecl("Nil",ConstType(Sort("List",[SortVar("a")])))])]),Strategies([SDefT("main_0_0",[],[],Seq(ImportTerm("./tests/strc_tests/test107.ctree"),Seq(Match(Anno(Explode(Anno(Str("Specification"),Wld),Wld),Wld)),Build(Anno(Str("ok"),Op("Nil",[]))))))])])
\ No newline at end of file
......@@ -7,6 +7,6 @@ imports libstratego-lib
strategies
main =
import-term(./Java-15.tbl)
; ?"parse-table"#(_)
import-term(./tests/strc_tests/test107.ctree)
; ?"Specification"#(_)
; !"ok"
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment