コード例 #1
0
ファイル: parser.py プロジェクト: maeberli/compireci
def p_error(p):
    p_error.error = True
    if p:
        print ("Syntax error in line %d" % p.lineno)
    else:
        print ("Syntax error: unexpected end of file!")
    yacc.restart()
コード例 #2
0
ファイル: parser.py プロジェクト: sansri264/CompilersProject
def p_error(p):
  
    flag=-1;
    # print dir(yacc)
    
    # assert(False)

    # print("Syntax error at '%s'" % p.value),
    # print('\t Error: {}'.format(p))

    while 1:

        tok = yacc.token()             # Get the next token
        if not tok:
            flag=1
            break
        if tok.type == 'STATE_END': 
            flag=0
            break

    if flag==0:
        yacc.errok()
        return tok
    else:
        yacc.restart()
コード例 #3
0
def p_error(p):
    print "Error de sintaxis en la linea",
    print p.lineno -1 ,
    print ", columna: " + str(find_column(p.lexer.lexdata,p)),
    print ": token inesperado:",
    print p.value
    yacc.restart()
コード例 #4
0
def p_error(t):
    global error_count
    global ok_count
    global last_error_token
    global last_error_line
    error_count += 1
    if t is not None:
        if last_error_token is None or t.lexpos != getattr(last_error_token,"lexpos",None):
            if abs(last_error_line -  t.lineno) > 3 and ok_count > 2:
                try: print_context(t)
                except: pass
                last_error_line = t.lineno
            yacc.errok()
            ok_count = 0
            return

    ok_count = 0
    if t is None:
        if last_error_token != "EOF": 
            print "ERROR: End of the file reached."
        last_error_token = "EOF"
        return t
    t = yacc.token() 
    yacc.restart()
    last_error_token = t
    return t
コード例 #5
0
ファイル: sintatica.py プロジェクト: AnaFrozza/Compiladores
 def p_erro(self, p):
     if p:
         print("Erro Sintático: %s, linha %d \n" % (p.valor, p.lineno))
     else:
         yacc.restart()
         print("Erro Sintático: definições incompletas!")
     exit(1)
コード例 #6
0
def p_error(p):

    flag = -1
    # print dir(yacc)

    # assert(False)

    # print("Syntax error at '%s'" % p.value),
    # print('\t Error: {}'.format(p))

    while 1:

        tok = yacc.token()  # Get the next token
        if not tok:
            flag = 1
            break
        if tok.type == 'STATE_END':
            flag = 0
            break

    if flag == 0:
        yacc.errok()
        return tok
    else:
        yacc.restart()
コード例 #7
0
def p_error(t):
    if t:
        print ("Erro sintático: '%s' Linha '%d" % (t.value, t.lineno))
        exit(1)
    else:
        yacc.restart()
        print ("Erro sintático")
        exit(1)
コード例 #8
0
 def p_error(self, p):
     if p:
         print(
             "erro sintático: não foi possível reconher '%s' na linha %d" %
             (p.value, p.lineno))
     else:
         yacc.restart()
         print("erro sintático: definições incompletas!")
コード例 #9
0
 def p_error(self, p):
     if p:
         print("Erro sintático: '%s', linha %d" % (p.value, p.lineno))
         exit(1)
     else:
         yacc.restart()
         print('Erro sintático: definições incompletas!')
         exit(1)
コード例 #10
0
ファイル: parser.py プロジェクト: maisab/Compilador
def p_error(p):
    if p:
        print("Erro sintático: '%s', linha %d" % (p.value, p.lineno))
        exit(1)
        #p.lexer.skip(1)
    else:
        yacc.restart()
        print('Erro sintático: definições incompletas!')
        exit(1)
コード例 #11
0
def p_error(p):
    if p:
        # print("Erro sintático na linha %d - Posição %d: '%s'" % (p.lineno, p.lexpos, p.value))
        print("Erro sintático na linha %d: '%s' após sentença estranha" %
              (p.lineno - 20, p.value))
        exit(1)
    else:
        yacc.restart()
        print("Erro sintático nas definições!")
        exit(1)
コード例 #12
0
ファイル: Cparser.py プロジェクト: knawrot/TextEditor
 def p_error(self, p):
      if p:
           self.error = True
           print("Syntax error at line {0}, column {1}: LexToken({2}, '{3}')".format(p.lineno, self.scanner.find_tok_column(p), p.type, p.value))
           while 1:
           	       tok = yacc.token()
           	       if not tok or tok.type == 'RBRACE': break
           yacc.restart()
      else:
           print('At end of input')
コード例 #13
0
ファイル: pyre.py プロジェクト: dscorbett/pyre
def p_error(p):
    """Fail, and go to the next line."""
    try:
        sys.stderr.write('Syntax error on line %d on token %s\n' %
                         (p.lexer.lineno, p.type))
    except AttributeError:
        sys.stderr.write('Unexpected EOL\n')
    while True:
        tok = yacc.token()
        if not tok: break
    yacc.restart()
コード例 #14
0
def p_error(p):
    if p:
        print("Line %d: Syntax error at '%s'" % (p.lineno, p.value))
    # Scan ahead looking for a name token
    while True:
        tok = yacc.token()
        if not tok or tok.type == 'RPAREN':
            break
    if tok:
        yacc.restart()
    return None
コード例 #15
0
ファイル: yacc_error7.py プロジェクト: 4sp1r3/ply
def p_error(p):
    if p:
        print("Line %d: Syntax error at '%s'" % (p.lineno, p.value))
    # Scan ahead looking for a name token
    while True:
        tok = yacc.token()
        if not tok or tok.type == 'RPAREN':
            break
    if tok:
        yacc.restart()
    return None
コード例 #16
0
ファイル: mvalid.py プロジェクト: paradigmsort/MagicValidate
def p_error(p):
    print("Error at " + str(p))
    # look for the blank line separating block
    while 1:
        tok = yacc.token()
        if not tok:
            break
        if tok.type == 'BLANK_LINE':
            yacc.restart()
            yacc.errok()
            return yacc.token()  # return the next line after the blank
コード例 #17
0
ファイル: pcl_parser.py プロジェクト: ebay-hlt/mosesdecoder
def p_error(token):
    if not token:
        print >> sys.stderr, "ERROR: Unexpected EOF"
    else:
        print >> sys.stderr, "ERROR: line %d parser failure at or near %s" % \
                             (token.lineno, token.type)

        while True:
            tok = yacc.token()
            if not tok or tok.type in recovery_tokens:
                break
        yacc.restart()
コード例 #18
0
ファイル: Parser.py プロジェクト: GaetanLhoest/NXLT
def p_error(p):
	if p:
		if p.type == 'NEWLINE':
			print("Syntax error :  %s aka %s is not attempt at line %s." % (p.type, "'line jump'", nlines))
		else:
			print("Syntax error :  %s aka %s is not attempt at line %s." % (p.type, str(p.value), nlines))
		while 1:
			tok = yacc.token()             # Get the next token
			if not tok or tok.type == 'NEWLINE': 
		 		break
		yacc.restart()
	else:
		print("Syntax error at EOF")
コード例 #19
0
ファイル: id.py プロジェクト: stephenhay/dexy
def p_error(p):
    if not p:
        raise ParseError("Reached EOF when parsing file using idioipdae.")

    lines = p.lexer.lexdata.splitlines()
    this_line = lines[p.lineno - 1]

    # Add whole line.
    append_text(p.lexer, this_line + "\n")

    # Forward input to end of line
    while 1:
        tok = yacc.token()
        if not tok or tok.type == 'NEWLINE': break

    yacc.restart()
コード例 #20
0
ファイル: bcmd_yacc.py プロジェクト: walkymatt/BCMD
def p_error(p):
    global compilationInfo
    compilationInfo['errors'].append(p)
    if None == p:
        print >> sys.stderr, 'Syntax error (unexpected EOF)'
        compilationInfo['messages'].append('Syntax error: unexpected EOF')
        compilationInfo['lines'].append('END')
        compilationInfo['files'].append(currentFile)
    else:
        print >> sys.stderr, 'Syntax error at token:', p
        compilationInfo['messages'].append("Syntax error at token '%s' [%s]" % (p.value, p.type))
        compilationInfo['lines'].append(p.lineno)
        compilationInfo['files'].append(currentFile)
        while 1:
            tok = yacc.token()
            if not tok or tok.type == 'END': break
        yacc.restart()
コード例 #21
0
ファイル: simple_yacc.py プロジェクト: FashtimeDotCom/GeekCMS
def p_error(p):
    # print("Syntax Error: '{}' in line {}".format(p.value, p.lineno))
    discard = [p.value]
    while True:
        token = yacc.token()
        if token and token.type != 'NEWLINE':
            discard.append(token.value)
            continue
        else:
            val = '[NEWLINE]' if token else '[EOL]'
            discard.append(val)
            break
    # print('Discard: ', ''.join(discard))
    ErrorCollector.add_yacc_message(
        (p.value, p.lineno, ''.join(discard)),
    )
    yacc.restart()
コード例 #22
0
ファイル: flscriptparse.py プロジェクト: sbellver/pineboo
def p_error(t):
    global error_count
    global ok_count
    global last_error_token
    global last_error_line, seen_tokens, last_ok_token
    debug = False  # Poner a True para toneladas de debug.
    # if error_count == 0: print
    if t is not None:
        if last_error_token is None or t.lexpos != getattr(
                last_error_token, "lexpos", None):
            if abs(last_error_line -
                   t.lineno) > 4 and ok_count > 1 and error_count < 4:
                error_count += 1
                try:
                    print_context(t)
                except:
                    pass
                if debug == True:
                    for tokname, tokln, tokdata in seen_tokens[-32:]:
                        if tokln == t.lineno:
                            print(tokname, tokdata)
                    print(repr(last_ok_token[0]))
                last_error_line = t.lineno
            elif abs(last_error_line - t.lineno) > 1 and ok_count > 1:
                last_error_line = t.lineno
            yacc.errok()
            ok_count = 0
            return

    ok_count = 0
    if t is None:
        if last_error_token != "EOF":
            print("ERROR: End of the file reached.")
            global endoffile
            print("Last data:", endoffile)

        last_error_token = "EOF"
        return t
    t = yacc.token()
    yacc.restart()
    last_error_token = t
    return t
コード例 #23
0
ファイル: flscriptparse.py プロジェクト: sbellver/pineboo
def p_error(t):
    global error_count
    global ok_count
    global last_error_token
    global last_error_line, seen_tokens, last_ok_token
    debug = False  # Poner a True para toneladas de debug.
    # if error_count == 0: print
    if t is not None:
        if last_error_token is None or t.lexpos != getattr(
                last_error_token, "lexpos", None):
            if abs(last_error_line -
                   t.lineno) > 4 and ok_count > 1 and error_count < 4:
                error_count += 1
                try:
                    print_context(t)
                except:
                    pass
                if debug == True:
                    for tokname, tokln, tokdata in seen_tokens[-32:]:
                        if tokln == t.lineno:
                            print(tokname, tokdata)
                    print(repr(last_ok_token[0]))
                last_error_line = t.lineno
            elif abs(last_error_line - t.lineno) > 1 and ok_count > 1:
                last_error_line = t.lineno
            yacc.errok()
            ok_count = 0
            return

    ok_count = 0
    if t is None:
        if last_error_token != "EOF":
            print("ERROR: End of the file reached.")
            global endoffile
            print("Last data:", endoffile)

        last_error_token = "EOF"
        return t
    t = yacc.token()
    yacc.restart()
    last_error_token = t
    return t
コード例 #24
0
ファイル: parse.py プロジェクト: pollow/CoreSML
def p_error(p):
    if p:
        print(colors.error("Syntax error near '%s' at line %d, %d" % (p.value, p.lineno, p.lexpos)))
    else:
        print(colors.error("Syntax error at EOF"))
    if error_handle == 1:
        print("Trying to discard the token '%s'" % p.value)
        yacc.errok()
    elif error_handle == 2:
        print("Trying to discard the whole sentence which includes '%s'" % p.value)
        while 1:
            tok = yacc.token()  # Get the next token
            if not tok or tok.type == ';':
                break
        yacc.restart()
    elif error_handle == 3:
        print(colors.error("It won't be fixed in p_error"))
        pass
    else:
        print(colors.error("Nothing would take place to fix the error"))
    errflag[0] = True
コード例 #25
0
ファイル: parser.py プロジェクト: AdolfoCastro/CACHACA-PLY
def p_error(t):
	print "Sorry, what did you mean by %s, at line %d?"%(t.value,t.lexer.lineno)
	print "Sorry - Syntax error at token", t.value ,">>", t.type
	sys.exit()
	# Just discard the token and tell the parser it's okay.
	yacc.restart()
コード例 #26
0
ファイル: parser.py プロジェクト: ggaughan/logo140
def p_error(p):
    print "Syntax error in input! %s" % (p)
    yacc.restart()
コード例 #27
0
def p_error(p):
    perrors.append(p)
    while 1:
        tok = yacc.token()
        if not tok or tok.value == '}': break
    yacc.restart()
コード例 #28
0
def p_error(p):
    if not p:
        print "There is a catastrophic error in your code. I cannot help you."
    else:
        print "Syntax error at line %s near %s" % (p.lineno, p.value)
        yacc.restart()
コード例 #29
0
ファイル: topology.py プロジェクト: yyforbidden/EPC_Test
 def p_error(self, p):
     if p:
         logger.warn('Syntax Error: line %d near "%s"' % (p.lexer.lineno, p.value))
         yacc.restart()
     else:
         logger.warn('Syntax Error at the end of file or file is empty')
コード例 #30
0
ファイル: lool.py プロジェクト: jamesproud/Lool
def parse(text):
	output = yacc.parse(text)
	yacc.restart()
	return output
コード例 #31
0
def p_error(p):  # noqa:pep257
    if not p:
        print("There is a catastrophic error in your code. I cannot help you.")
    else:
        print("Syntax error at line %s near %s" % (p.lineno, p.value))
        yacc.restart()