self.compile_query_line(term, term_loc, code, num_perm_vars, is_exposed);
if self.marker.max_reg_allocated() > MAX_ARITY {
- return Err(CompilationError::from(ParserError::ExceededMaxArity));
+ return Err(CompilationError::ExceededMaxArity);
}
}
}
let mut fact = self.compile_target::<FactInstruction, _>(iter, GenContext::Head, false);
if self.marker.max_reg_allocated() > MAX_ARITY {
- return Err(CompilationError::from(ParserError::ExceededMaxArity));
+ return Err(CompilationError::ExceededMaxArity);
}
let mut unsafe_var_marker = UnsafeVarMarker::new();
);
if self.marker.max_reg_allocated() > MAX_ARITY {
- return Err(CompilationError::from(ParserError::ExceededMaxArity));
+ return Err(CompilationError::ExceededMaxArity);
}
self.mark_unsafe_fact_vars(&mut compiled_fact);
let value = self.machine_st.registers[2];
unify_fn!(&mut self.machine_st, value, heap_loc_as_cell!(offset.heap_loc));
}
- Err(ParserError::UnexpectedEOF) => {
+ Err(CompilationError::ParserError(ParserError::UnexpectedEOF)) => {
let value = self.machine_st.registers[2];
self.machine_st.unify_atom(atom!("end_of_file"), value);
}
SessionError::OpIsInfixAndPostFix(op) => {
self.permission_error(Permission::Create, atom!("operator"), functor!(op))
}
+ SessionError::CompilationError(CompilationError::ExceededMaxArity) => {
+ self.representation_error(RepFlag::MaxArity)
+ }
SessionError::CompilationError(err) => self.syntax_error(err),
SessionError::PredicateNotMultifileOrDiscontiguous(compilation_target, key) => {
let functor_stub = functor_stub(key.0, key.1);
Arithmetic(ArithmeticError),
ParserError(ParserError),
CannotParseCyclicTerm,
+ ExceededMaxArity,
ExpectedRel,
InadmissibleFact,
InadmissibleQueryTerm,
&CompilationError::CannotParseCyclicTerm => {
functor!(atom!("cannot_parse_cyclic_term"))
}
+ &CompilationError::ExceededMaxArity => {
+ functor!(atom!("exceeded_max_arity"))
+ }
&CompilationError::ExpectedRel => {
functor!(atom!("expected_relation"))
}
pub enum SessionError {
CompilationError(CompilationError),
CannotOverwriteBuiltIn(PredicateKey),
- // CannotOverwriteImport(Atom),
ExistenceError(ExistenceError),
- // InvalidFileName(Atom),
ModuleDoesNotContainExport(Atom, PredicateKey),
ModuleCannotImportSelf(Atom),
NamelessEntry,
return Ok(unify_fn!(*self, var_names_offset, var_names_addr));
}
Err(err) => {
- if let ParserError::UnexpectedEOF = err {
+ if let CompilationError::ParserError(ParserError::UnexpectedEOF) = err {
self.eof_action(
self.registers[2],
stream,
pub fn write_parsed_term_to_heap(
&mut self,
input_stream: Stream,
- ) -> Result<TermWriteResult, ParserError> {
+ ) -> Result<TermWriteResult, CompilationError> {
self.machine_st.read(input_stream, &self.op_dir)
}
pub fn parse_and_write_parsed_term_to_heap(
&mut self,
term_string: &'static str,
- ) -> Result<TermWriteResult, ParserError> {
+ ) -> Result<TermWriteResult, CompilationError> {
let stream = Stream::from_static_string(term_string, &mut self.machine_st.arena);
self.write_parsed_term_to_heap(stream)
}
pub fn parse_and_print_term(
&mut self,
term_string: &'static str,
- ) -> Result<String, ParserError> {
+ ) -> Result<String, CompilationError> {
let term_write_result = self.parse_and_write_parsed_term_to_heap(term_string)?;
print_heap_terms(self.machine_st.heap.iter(), term_write_result.heap_loc);
machine_st: &mut MachineState,
input_stream: Stream,
op_dir: &OpDir,
-) -> Result<TermWriteResult, ParserError> {
+) -> Result<TermWriteResult, CompilationError> {
machine_st.read(input_stream, op_dir)
}
machine_st: &mut MachineState,
term_string: &'static str,
op_dir: &OpDir,
-) -> Result<TermWriteResult, ParserError> {
+) -> Result<TermWriteResult, CompilationError> {
let stream = Stream::from_static_string(term_string, &mut machine_st.arena);
write_parsed_term_to_heap(machine_st, stream, op_dir)
}
#[derive(Debug)]
pub enum ParserError {
BackQuotedString(usize, usize),
- ExceededMaxArity,
IO(IOError),
IncompleteReduction(usize, usize),
InvalidSingleQuotedCharacter(char),
pub fn as_atom(&self) -> Atom {
match self {
ParserError::BackQuotedString(..) => atom!("back_quoted_string"),
- ParserError::ExceededMaxArity => atom!("exceeded_max_arity"),
ParserError::IncompleteReduction(..) => atom!("incomplete_reduction"),
ParserError::InvalidSingleQuotedCharacter(..) => atom!("invalid_single_quoted_character"),
ParserError::IO(_) => atom!("input_output_error"),
use crate::forms::*;
use crate::iterators::*;
use crate::machine::heap::*;
+use crate::machine::machine_errors::*;
use crate::machine::machine_indices::*;
use crate::machine::machine_state::MachineState;
use crate::machine::streams::*;
&mut self,
mut inner: Stream,
op_dir: &OpDir,
- ) -> Result<TermWriteResult, ParserError> {
+ ) -> Result<TermWriteResult, CompilationError> {
let (term, num_lines_read) = {
let prior_num_lines_read = inner.lines_read();
let mut parser = Parser::new(inner, self);
parser.add_lines_read(prior_num_lines_read);
- let term = parser.read_term(&CompositeOpDir::new(op_dir, None))?;
+ let term = parser.read_term(&CompositeOpDir::new(op_dir, None))
+ .map_err(CompilationError::from)?;
+
(term, parser.lines_read() - prior_num_lines_read)
};
term: &Term,
heap: &mut Heap,
atom_tbl: &mut AtomTable,
-) -> Result<TermWriteResult, ParserError> {
+) -> Result<TermWriteResult, CompilationError> {
let term_writer = TermWriter::new(heap, atom_tbl);
term_writer.write_term_to_heap(term)
}
}
}
- fn write_term_to_heap(mut self, term: &'a Term) -> Result<TermWriteResult, ParserError> {
+ fn write_term_to_heap(mut self, term: &'a Term) -> Result<TermWriteResult, CompilationError> {
let heap_loc = self.heap.len();
for term in breadth_first_iter(term, true) {
}
&TermRef::Clause(Level::Root, _, ref ct, subterms) => {
if subterms.len() > MAX_ARITY {
- return Err(ParserError::ExceededMaxArity);
+ return Err(CompilationError::ExceededMaxArity);
}
self.heap.push(if subterms.len() == 0 {