如何为TEX创建解析器? [英] how to create parser for TEX?

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

问题描述

我期待开发出TEX解析器,现在的问题是有没有上下文无关文法,并不能有一个,因为它不是上下文无关语言,我听说它是​​某种宏语言和建立在其自己的。



所以,现在我需要什么样的语法这个宏语言已经和如何在C#中建立什么方向发展。



我会写标记生成器和分析器,但我需要在TEX宏一些规则,这是很难找到,其他地方还有关于如何使用TEX宏的文档。


< DIV CLASS =h2_lin>解决方案

的TeX作为一种编程语言也许是曾经与一个庞大的保留字量创造了最复杂的(非深奥的)语言。因为它是由处理器和一般做的事情,你在分析的语言通常不会遇到读你可以重新映射每个字符的含义。



如果你真的想创建自己的TeX的解析器,你将不得不建立在原来的TeX。源代码,不仅可用,但它写成一个 使用Knuth的WEB巧妙识字工具程序



要复杂的问题进一步始终使用宏包使用TeX的。默认的包是平原和最知名的是乳液。宏包中,你将不得不纳入到能够解析要解析的TeX的特殊的方言的代码不平凡的量。


I am looking to develop a TEX parser, now problem is there is no Context Free Grammar and there can not be one, because its not context free language, I heard that it is some sort of macro language and that builds on its own.

So now I need direction of what kind of grammar this macro language has and how to build anything upon in c#.

I will write the tokenizer and parser, but I need some rules of macro in TEX which are quite hard to find, everywhere else there is documentation about how to use TEX macros.

解决方案

TeX as a programming language is perhaps the most complex (non-esoteric) language ever created with a huge amount of "reserved words". You can remap the meaning of every character as it is read by the processor and in general do things you don't normally encounter while parsing a language.

If you really want to create your own TeX parser you will have to build on the original TeX. The source code is not only available, but it is written as a literate program using Knuth's ingenious WEB tool.

To complicate matters further you always use a macro package with TeX. The default package is Plain and the most well known is LaTeX. The macro package contains a non-trivial amount of code you will have to incorporate to be able to parse the particular "dialect" of TeX you want to parse.

这篇关于如何为TEX创建解析器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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