示例#1
0
文件: errors.py 项目: wizeline/wfc
 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
示例#2
0
 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))
示例#3
0
    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
示例#4
0
文件: commons.py 项目: wizeline/wfc
def get_position_from_context(context):
    return parglare.pos_to_line_col(context.input_str, context.start_position)