Tcl file parser for PYTHON

半城伤御伤魂 提交于 2019-12-13 18:28:47

问题


I have a .tcl file.

Is there any parser available which directly extracts data from .tcl file ? I don't want to use REGEX for this task. Is pyparsing will work for this problem ?

I am using Python 2.7


回答1:


.tcl files are not data files, they are programming scripts, written in the Tcl programming language.

The Tcl language is extremely flexible in form and style, which makes writing a general-purpose parser a substantial project, whether in pyparsing or any other package. I encourage people, when they are embarking on a new pyparsing project, to begin by roughing out the BNF for the language, to whatever level of detail they want. This page from the Tcl wiki implies that developing a BNF for Tcl is not at all straightforward, if even possible.

It is very unlikely that anyone will respond to your question with an answer containing your Tcl-parser-implemented-in-Python. Perhaps there is a Tcl subset that you are particularly focused on - if you were to post some sample Tcl code and what you want to get from it, you are more likely to get helpful responses.



来源:https://stackoverflow.com/questions/26288633/tcl-file-parser-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!