def __init__(self, input_path, context): self.input_path = os.path.abspath(input_path) if context: position = parglare.pos_to_line_col(context.input_str, context.start_position) self.line, self.column = position else: self.line, self.column = None, None
def __str__(self): if self.message: return self.message else: from parglare import pos_to_line_col line, col = pos_to_line_col(input, self.position) return "Unexpected input at position {}. Expected: {}"\ .format((line, col), expected_symbols_str(self.expected_symbols))
def prod_callable(new_nt): if sep_ref: from parglare import pos_to_line_col raise GrammarError('Repetition modifier not allowed for ' 'optional (?) for symbol "{}" at {}.'.format( gsymbol.name, pos_to_line_col(context.input_str, context.start_position))) # Optional new_productions = [ Production(new_nt, ProductionRHS([gsymbol])), Production(new_nt, ProductionRHS([EMPTY])) ] return new_productions
def get_position_from_context(context): return parglare.pos_to_line_col(context.input_str, context.start_position)