可以解析C代码的最简单的解析算法是什么? [英] What is the simplest parsing algorithm that can parse C code?

查看:92
本文介绍了可以解析C代码的最简单的解析算法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道可以解析C代码的最薄弱的广泛使用的解析算法家族是什么吗?也就是说,C语法是LL(1),LR(0),LALR(1)等吗?我很好奇,因为作为辅助项目,我有兴趣为这些系列中的一个编写一个解析器生成器,并希望最终能够为另一个辅助项目解析C代码.

Does anyone know what the weakest family of widely-used parsing algorithms is that can parse C code? That is, is the C grammar LL(1), LR(0), LALR(1), etc.? I'm curious because as a side project I'm interested in writing a parser generator for one of these families and would like to ultimately be able to parse C code for another side project.

推荐答案

似乎

It seems that Bison uses an LALR(1) parser. LALR parsers are more robust than LL parsers, but are also more complex. From this I suspect that LALR(1) is probably the weakest parsing algorithm which can parse C code.

除非您真的打算使用自己的识别器. ANTLR 可能是您最好的选择. ANTLR使用LL *算法(实际上是LALR).

Unless you're really set on rolling your own recognizer. ANTLR would probably be your best bet to do this. ANTLR uses an LL* algorithm (which is, effectively, LALR).

这篇关于可以解析C代码的最简单的解析算法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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