由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Smart Parser/Compiler Development
相关主题
请教一个parser的问题哎,本来想从讨论中学些东西
实现一个parser可以解析给定的几种sql语句,怎么做? (转载)推荐个html parser的库?
谁知道如何调试yacc程序?Question about a C++ compilation error on Visual Studio 2005
int *a [] 和int (*a)[] 一样吗Compiler
i +++ j有没有独立的lgpl版权的c/cpp语言写的xml parser?
[合集] 被perl雷到了,sed, awk, cygwin, native以及其他newbie python question
王垠对google的看法 (转载)yacc/bison的调试和分析工具?
有没有这样的blind JSON parserany perl html parser to recommend?
相关话题的讨论汇总
话题: parser话题: smart话题: compiler话题: some
进入Programming版参与讨论
1 (共1页)
g*********s
发帖数: 1782
1
Hi, can any guru give some suggestion on how to develop a smart parser/
compiler
given a set of syntax definition?
By "smart" I mean the parser can skip some errors and continue, like gcc
does in some situation. I hope to learn some general principles on this
issue.
Thanks!
c*****t
发帖数: 1879
2
For LR parsers, when a set of tokens couldn't be reduced, there is a
error. At this point, you can decided on a case by case basis to
manipulate the parsing stack or directly generate an error.
For LL parsers, if your look ahead token isn't what you expect (such
as missing ';'), you can insert this pretty easily. Usually LL parsers
is a bit easier for this kind of stuff.
I'd say don't waste your time on itt. It's really not that importat.

【在 g*********s 的大作中提到】
: Hi, can any guru give some suggestion on how to develop a smart parser/
: compiler
: given a set of syntax definition?
: By "smart" I mean the parser can skip some errors and continue, like gcc
: does in some situation. I hope to learn some general principles on this
: issue.
: Thanks!

d****2
发帖数: 6250
3
bison supports "error" token, you can do whatever you want.
N********n
发帖数: 8363
4
The idea is simple: Add additional rules to track potential errors.
Like switch case statements:
switch (status)
case 0 : // do status 0
...
case 1 : // do status 1
...
case 2 : // wrong, status 2 is caused by some certain mistake
generateErrorReportOnStatus2 ();
... ...
"case 2" is an example of the additional rules.


【在 g*********s 的大作中提到】
: Hi, can any guru give some suggestion on how to develop a smart parser/
: compiler
: given a set of syntax definition?
: By "smart" I mean the parser can skip some errors and continue, like gcc
: does in some situation. I hope to learn some general principles on this
: issue.
: Thanks!

1 (共1页)
进入Programming版参与讨论
相关主题
any perl html parser to recommend?i +++ j
any lexer/parser enthusiasts here?[合集] 被perl雷到了,sed, awk, cygwin, native以及其他
怎么可以取出网页中更新的内容 ?王垠对google的看法 (转载)
一个popen加gzip的问题有没有这样的blind JSON parser
请教一个parser的问题哎,本来想从讨论中学些东西
实现一个parser可以解析给定的几种sql语句,怎么做? (转载)推荐个html parser的库?
谁知道如何调试yacc程序?Question about a C++ compilation error on Visual Studio 2005
int *a [] 和int (*a)[] 一样吗Compiler
相关话题的讨论汇总
话题: parser话题: smart话题: compiler话题: some