Added $scryer_prolog_version/1
This commit is contained in:
@@ -36,11 +36,6 @@ fn main() {
|
|||||||
let handler = signal::SigHandler::Handler(handle_sigint);
|
let handler = signal::SigHandler::Handler(handle_sigint);
|
||||||
unsafe { signal::signal(signal::Signal::SIGINT, handler) }.unwrap();
|
unsafe { signal::signal(signal::Signal::SIGINT, handler) }.unwrap();
|
||||||
|
|
||||||
if env::args().skip(1).any(|a| a == "-v" || a == "--version") {
|
|
||||||
println!("{:}", git_version!(cargo_prefix = "cargo:", fallback = "unknown"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut wam = Machine::new(readline::input_stream(), Stream::stdout());
|
let mut wam = Machine::new(readline::input_stream(), Stream::stdout());
|
||||||
wam.run_top_level();
|
wam.run_top_level();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,6 +264,7 @@ pub enum SystemClauseType {
|
|||||||
WAMInstructions,
|
WAMInstructions,
|
||||||
WriteTerm,
|
WriteTerm,
|
||||||
WriteTermToChars,
|
WriteTermToChars,
|
||||||
|
ScryerPrologVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SystemClauseType {
|
impl SystemClauseType {
|
||||||
@@ -418,6 +419,7 @@ impl SystemClauseType {
|
|||||||
&SystemClauseType::WAMInstructions => clause_name!("$wam_instructions"),
|
&SystemClauseType::WAMInstructions => clause_name!("$wam_instructions"),
|
||||||
&SystemClauseType::WriteTerm => clause_name!("$write_term"),
|
&SystemClauseType::WriteTerm => clause_name!("$write_term"),
|
||||||
&SystemClauseType::WriteTermToChars => clause_name!("$write_term_to_chars"),
|
&SystemClauseType::WriteTermToChars => clause_name!("$write_term_to_chars"),
|
||||||
|
&SystemClauseType::ScryerPrologVersion => clause_name!("$scryer_prolog_version"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,6 +554,7 @@ impl SystemClauseType {
|
|||||||
("$wam_instructions", 3) => Some(SystemClauseType::WAMInstructions),
|
("$wam_instructions", 3) => Some(SystemClauseType::WAMInstructions),
|
||||||
("$write_term", 6) => Some(SystemClauseType::WriteTerm),
|
("$write_term", 6) => Some(SystemClauseType::WriteTerm),
|
||||||
("$write_term_to_chars", 7) => Some(SystemClauseType::WriteTermToChars),
|
("$write_term_to_chars", 7) => Some(SystemClauseType::WriteTermToChars),
|
||||||
|
("$scryer_prolog_version", 1) => Some(SystemClauseType::ScryerPrologVersion),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3543,6 +3543,15 @@ impl MachineState {
|
|||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&SystemClauseType::ScryerPrologVersion => {
|
||||||
|
use crate::git_version::git_version;
|
||||||
|
let version = self[temp_v!(1)];
|
||||||
|
let buffer =
|
||||||
|
git_version!(cargo_prefix = "cargo:", fallback = "unknown");
|
||||||
|
let chars = buffer.chars().map(|c| Addr::Char(c));
|
||||||
|
let result = Addr::HeapCell(self.heap.to_list(chars));
|
||||||
|
self.unify(version, result);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return_from_clause!(self.last_call, self)
|
return_from_clause!(self.last_call, self)
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ delegate_task([], Goals0) :-
|
|||||||
run_goals(Goals),
|
run_goals(Goals),
|
||||||
repl.
|
repl.
|
||||||
delegate_task([Arg0|Args], Goals0) :-
|
delegate_task([Arg0|Args], Goals0) :-
|
||||||
( member(Arg0, ["-h", "--help"]) -> print_help(Args)
|
( member(Arg0, ["-h", "--help"]) -> print_help
|
||||||
; member(Arg0, ["-v", "--version"]) -> print_version(Args)
|
; member(Arg0, ["-v", "--version"]) -> print_version
|
||||||
; member(Arg0, ["-g", "--goal"]) -> gather_goal(g, Args, Goals0)
|
; member(Arg0, ["-g", "--goal"]) -> gather_goal(g, Args, Goals0)
|
||||||
; atom_chars(Mod, Arg0),
|
; atom_chars(Mod, Arg0),
|
||||||
catch(use_module(Mod), E, print_exception(E))
|
catch(use_module(Mod), E, print_exception(E))
|
||||||
),
|
),
|
||||||
delegate_task(Args, Goals0).
|
delegate_task(Args, Goals0).
|
||||||
|
|
||||||
print_help(_) :-
|
print_help :-
|
||||||
write('Usage: scryer-prolog [OPTIONS] [FILES] [-- ARGUMENTS]'),
|
write('Usage: scryer-prolog [OPTIONS] [FILES] [-- ARGUMENTS]'),
|
||||||
nl, nl,
|
nl, nl,
|
||||||
write('Options:'), nl,
|
write('Options:'), nl,
|
||||||
@@ -51,22 +51,18 @@ print_help(_) :-
|
|||||||
% write(' '),
|
% write(' '),
|
||||||
halt.
|
halt.
|
||||||
|
|
||||||
print_version(_) :-
|
print_version :-
|
||||||
'$scryer_prolog_version'(Version),
|
'$scryer_prolog_version'(Version),
|
||||||
write(Version), nl,
|
write(Version), nl,
|
||||||
halt.
|
halt.
|
||||||
|
|
||||||
gather_goal(Type, Args0, Goals) :-
|
gather_goal(Type, Args0, Goals) :-
|
||||||
length(Args0, N),
|
length(Args0, N),
|
||||||
( N < 1 -> print_help(_), halt
|
( N < 1 -> print_help, halt
|
||||||
; true
|
; true
|
||||||
),
|
),
|
||||||
[Gs1|Args] = Args0,
|
[Gs1|Args] = Args0,
|
||||||
( Type = g -> Gs =.. [Type, Gs1]
|
Gs =.. [Type, Gs1],
|
||||||
; write('caught: '),
|
|
||||||
write(error(domain_error(arg_type, Type), gather_goal/3)), nl,
|
|
||||||
halt
|
|
||||||
),
|
|
||||||
delegate_task(Args, [Gs|Goals]).
|
delegate_task(Args, [Gs|Goals]).
|
||||||
|
|
||||||
arg_type(g).
|
arg_type(g).
|
||||||
|
|||||||
Reference in New Issue
Block a user