Example #1
0
File: lx.py Project: kr/sodium
 def annotate_or_report(self, exp):
     self.context = (exp,) + getattr(self, 'context', ())
     if self.context[0:1] == self.context[1:2]:
       self.context = self.context[1:]
     while exp not in reader.current_pos_info:
       if not pairp(exp): raise self
       exp = exp.car()
     info = reader.current_pos_info[exp]
     report_compile_error(self, file=info[0], line=info[1], char=info[2])
Example #2
0
File: reader.py Project: kr/sodium
 def match(self, *types):
     peek, lexeme = self.peek, self.lexeme
     if peek not in types:
         if len(types) > 1:
             more = '\n  expected one of: ' + ', '.join(map(T.name, types))
         else:
             more = ' expected ' + T.name(types[0])
         ex = ReadError('found %s,%s' % (T.name(peek), more))
         report_compile_error(ex,
                 file=self.p[0], line=self.p[1], char=self.p[2])
     self.next()
     return lexeme
Example #3
0
File: reader.py Project: kr/sodium
def report_bad_escape(pos, s, i):
    ex = ReadError('bad escape sequence %s' % s[i:i + 4])
    report_compile_error(ex, file=pos[0], line=pos[1], char=pos[2] + 1 + i)