如何在 Google App Engine 上设置 PyParsing?

发布于 2024-08-03 01:17:37 字数 232 浏览 5 评论 0原文

我在 Google App Engine 文档中看到 http://www.antlr.org/ Antlr3 用作解析第三方库。

但据我所知,Pyparsing 似乎更容易使用,我的目标只是解析一些简单的语法。

还有其他选择吗?我可以在 App Engine 上使用 pyparsing 吗?

I saw on the Google App Engine documentation that http://www.antlr.org/ Antlr3 is used as the parsing third party library.

But from what I know Pyparsing seems to be the easier to use and I am only aiming to parse some simple syntax.

Is there an alternative? Can I get pyparsing working on the App Engine?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

帝王念 2024-08-10 01:17:37

为此目的,Pyparsing 的运行时占用空间特意较小。它是一个源文件 pyparsing.py,因此只需将其放入您自己的源文件中并解析即可!

——保罗

Pyparsing's runtime footprint is intentionally small for just this purpose. It is a single source file, pyparsing.py, so just drop it in amongst your own source files and parse away!

-- Paul

幸福丶如此 2024-08-10 01:17:37

“就这样做”!-)获取 pyparsing.py,例如来自 此处,并将其放入您的应用引擎应用的目录中;现在您只需在应用代码中导入 pyparsing 并使用它即可。

例如,将此处中的greeting.py调整为:

from pyparsing import Word, alphas
greet = Word( alphas ) + "," + Word( alphas ) + "!" # <-- grammar defined here
hello = "Hello, World!"
print "Content-type: text/plain\n"
print hello, "->", greet.parseString( hello )

添加到您的app.yaml 位于 handlers: 下的两行:

- url: /parshello
  script: greeting.py

启动您的应用程序,访问 http://localhost:8083/parshello (或您正在运行的任何端口;- ),您将在浏览器中看到纯文本输出:

Hello, World! -> ['Hello', ',', 'World', '!']

"Just do it"!-) Get pyparsing.py, e.g. from here, and put it in your app engine app's directory; now you can just import pyparsing in your app code and use it.

For example, tweak the greeting.py from here to be:

from pyparsing import Word, alphas
greet = Word( alphas ) + "," + Word( alphas ) + "!" # <-- grammar defined here
hello = "Hello, World!"
print "Content-type: text/plain\n"
print hello, "->", greet.parseString( hello )

add to your app.yaml right under handlers: the two lines:

- url: /parshello
  script: greeting.py

start your app, visit http://localhost:8083/parshello (or whatever port you're running on;-), and you'll see in your browser the plain text output:

Hello, World! -> ['Hello', ',', 'World', '!']
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文