aboutsummaryrefslogtreecommitdiffstats
path: root/tools/asn2wrs.py
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2019-06-22 19:42:11 +0100
committerPeter Wu <peter@lekensteyn.nl>2019-06-23 17:31:15 +0000
commit7dfcb4425adf29590f3daf507d667b330a97b669 (patch)
tree324aa6db35f15b2689b42a7205dd83bdbccaeb1a /tools/asn2wrs.py
parent99a87a68caf83eec37ac83ba7a8c3c6a051ff68e (diff)
asn2wrs: use system lex and yacc from ply if available
Tested with python-ply 3.11 and Python 3.7.3 on Arch Linux using the 'ninja asn1' command. Bundling lex.py and yacc.py is one distribution method suggested by PLY upstream (https://www.dabeaz.com/ply/README.txt), but since it is also available in many Linux distributions, we could potentially remove it in the future. Windows developers can install it through pip if needed. Change-Id: I9c847072916ee33da49994820b435ec1d7110303 Reviewed-on: https://code.wireshark.org/review/33708 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'tools/asn2wrs.py')
-rwxr-xr-xtools/asn2wrs.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/asn2wrs.py b/tools/asn2wrs.py
index 917b017f8e..41e7949efc 100755
--- a/tools/asn2wrs.py
+++ b/tools/asn2wrs.py
@@ -47,8 +47,14 @@ import time
import getopt
import traceback
-import lex
-import yacc
+try:
+ from ply import lex
+ from ply import yacc
+except ImportError:
+ # Fallback: use lex.py and yacc from the tools directory within the
+ # Wireshark source tree if python-ply is not installed.
+ import lex
+ import yacc
if sys.version_info[0] < 3:
from string import maketrans