Skip to content

Commit c96a931

Browse files
committed
plyparser.py is removed
1 parent c057135 commit c96a931

File tree

2 files changed

+25
-64
lines changed

2 files changed

+25
-64
lines changed

pyverilog/vparser/parser.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
import sys
2020
import os
2121
import pathlib
22-
2322
from ply.yacc import yacc
24-
from pyverilog.vparser.plyparser import PLYParser, ParseError
23+
2524
from pyverilog.vparser.preprocessor import VerilogPreprocessor
2625
from pyverilog.vparser.lexer import VerilogLexer
2726
from pyverilog.vparser.ast import *
2827

2928

30-
class VerilogParser(PLYParser):
29+
class VerilogParser(object):
3130
'Verilog HDL Parser'
3231

3332
# Expression Precedence
@@ -64,7 +63,8 @@ def __init__(self, outputdir=".", debug=True):
6463
)
6564

6665
def _lexer_error_func(self, msg, line, column):
67-
self._parse_error(msg, self._coord(line, column))
66+
coord = self._coord(line, column)
67+
raise ParseError('%s: %s' % (coord, msg))
6868

6969
def get_directives(self):
7070
return self.lexer.get_directives()
@@ -2265,13 +2265,29 @@ def p_empty(self, p):
22652265

22662266
# --------------------------------------------------------------------------
22672267
def p_error(self, p):
2268-
print("Syntax error")
2268+
self._raise_error(p)
2269+
2270+
# --------------------------------------------------------------------------
2271+
def _raise_error(self, p):
22692272
if p:
2270-
self._parse_error(
2271-
'before: %s' % p.value,
2272-
self._coord(p.lineno))
2273+
msg = 'before: "%s"' % p.value
2274+
coord = self._coord(p.lineno)
22732275
else:
2274-
self._parse_error('At end of input', '')
2276+
msg = 'at end of input'
2277+
coord = None
2278+
2279+
raise ParseError("%s: %s" % (coord, msg))
2280+
2281+
def _coord(self, lineno, column=None):
2282+
ret = [self.lexer.filename]
2283+
ret.append('line:%s' % lineno)
2284+
if column is not None:
2285+
ret.append('column:%s' % column)
2286+
return ' '.join(ret)
2287+
2288+
2289+
class ParseError(Exception):
2290+
pass
22752291

22762292

22772293
class VerilogCodeParser(object):

pyverilog/vparser/plyparser.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)