PYTHON 的 Tcl 文件解析器 [英] Tcl file parser for PYTHON

查看:115
本文介绍了PYTHON 的 Tcl 文件解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .tcl 文件.

I have a .tcl file.

是否有任何可以直接从 .tcl 文件中提取数据的解析器?我不想将 REGEX 用于此任务.pyparsing 可以解决这个问题吗?

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 ?

我使用的是 Python 2.7

I am using Python 2.7

推荐答案

.tcl 文件不是数据文件,它们是用 Tcl 编程语言编写的编程脚本.

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

Tcl 语言在形式和风格上极其灵活,这使得编写通用解析器成为一项重大项目,无论是在 pyparsing 还是任何其他包中.我鼓励人们,当他们开始一个新的 pyparsing 项目时,首先粗略地为该语言制定 BNF,无论他们想要什么细节级别.来自 Tcl wiki 的这个页面 暗示为 Tcl 开发 BNF 一点也不简单,如果可能的话.

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.

不太可能有人会用包含您的 Tcl-parser-implemented-in-Python 的答案来回答您的问题.也许有一个您特别关注的 Tcl 子集 - 如果您要发布一些示例 Tcl 代码以及您想从中获得什么,您更有可能得到有用的回复.

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.

这篇关于PYTHON 的 Tcl 文件解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆