parser-generator

What are the disadvantages of the Spirit parser-generator framework from boost.org?

こ雲淡風輕ζ 提交于 2019-12-03 01:37:50
问题 In several questions I've seen recommendations for the Spirit parser-generator framework from boost.org, but then in the comments there is grumbling from people using Spirit who are not happy. Will those people please stand forth and explain to the rest of us what are the drawbacks or downsides to using Spirit? 回答1: It is a quite cool idea, and I liked it; it was especially useful to really learn how to use C++ templates. But their documentation recommends the usage of spirit for small to

How can we get the Syntax Tree of TypeScript?

◇◆丶佛笑我妖孽 提交于 2019-12-02 20:33:14
Is there a process on getting a syntax tree of a compiler. We had been assigned on a project that needs to access typescript's syntax tree (which is opensource so we could see the whole compiler's code). But we don't know how to get it. I've been reading some articles in the Internet but I can't really find a user-friendly article or which is written in lehman's term. I believe some mentioned that the first step we need to do is to find the parsing step. But after that we had no idea what to do next. Sorry for the noob question. :) The TypeScript compiler API is really quite easy to use. To

What is the advantage of using a parser generator like happy as opposed to using parser combinators?

落爺英雄遲暮 提交于 2019-12-02 17:31:57
To learn how to write and parse a context-free grammar I want to choose a tool. For Haskell, there are two big options: Happy, which generates a parser from a grammar description and *Parsec, which allows you to directly code a parser in Haskell. What are the (dis)advantages of either approach? External vs internal DSL The parser specification format for Happy is an external DSL, whereas with Parsec you have the full power of Haskell available when defining your parsers. This means that you can for example write functions to generate parsers, use Template Haskell and so on. Precedence rules

What are the disadvantages of the Spirit parser-generator framework from boost.org?

此生再无相见时 提交于 2019-12-02 15:06:59
In several questions I've seen recommendations for the Spirit parser-generator framework from boost.org , but then in the comments there is grumbling from people using Spirit who are not happy. Will those people please stand forth and explain to the rest of us what are the drawbacks or downsides to using Spirit? It is a quite cool idea, and I liked it; it was especially useful to really learn how to use C++ templates. But their documentation recommends the usage of spirit for small to medium-size parsers. A parser for a full language would take ages to compile. I will list three reasons.

What advantages do LL parsers have over LR parsers?

≯℡__Kan透↙ 提交于 2019-12-02 14:30:58
What advantages do LL parsers have over LR parsers to warrant their relative popularity in today's parser generator tools ? According to Wikipedia , LR parsing appears to have advantages over LL: LR parsing can handle a larger range of languages than LL parsing, and is also better at error reporting, i.e. it detects syntactic errors when the input does not conform to the grammar as soon as possible. This is in contrast to an LL(k) (or even worse, an LL(*) parser) which may defer error detection to a different branch of the grammar due to backtracking, often making errors harder to localize

ANTLR parsing MismatchedTokenException

♀尐吖头ヾ 提交于 2019-12-02 06:42:45
I'm trying to write a simple parser for an even simpler language that I'm writing. It's composed of postfix expressions. As of now, I'm having issues with the parser. When I run it on the input 2 2 * test >> I get a MismatchedTokenException. Also, how would I go about implementing a recursive postfix parser? Here's my code: grammar star; options { language=Python; output=AST; ASTLabelType=CommonTree; } tokens {DECL;} //start // : decl ; //decl // : type ID -> ^(DECL type ID) // ; program : (body)+ ; body : (nested WS)* | (var WS)* | (get WS)* ; var : nested ID '>>' ; get : ID '<<' ; /

C# Lua Parser / Analyser

此生再无相见时 提交于 2019-12-01 08:46:45
first things first; I am writing a little LUA-Ide in C#. The code execution is done by an Assembly named LuaInterface. The code-editing is done by a Scintilla-Port & the RAD / UI Interface is via the extensible IDesignSurfaceExt Visual Studio (one way code generation). File handling is provided by a little sql-lite-db used as a project-package-file. So all in all i've got everything i need together... The only problem unsolved is the parser / lexer for lua. I do not want to load & execute the code! I just want to parse the String containing the Lua code and get some information about it like

C# Lua Parser / Analyser

守給你的承諾、 提交于 2019-12-01 06:47:36
问题 first things first; I am writing a little LUA-Ide in C#. The code execution is done by an Assembly named LuaInterface. The code-editing is done by a Scintilla-Port & the RAD / UI Interface is via the extensible IDesignSurfaceExt Visual Studio (one way code generation). File handling is provided by a little sql-lite-db used as a project-package-file. So all in all i've got everything i need together... The only problem unsolved is the parser / lexer for lua. I do not want to load & execute the

non-greedy matching in Scala RegexParsers

China☆狼群 提交于 2019-12-01 03:09:02
Suppose I'm writing a rudimentary SQL parser in Scala. I have the following: class Arith extends RegexParsers { def selectstatement: Parser[Any] = selectclause ~ fromclause def selectclause: Parser[Any] = "(?i)SELECT".r ~ tokens def fromclause: Parser[Any] = "(?i)FROM".r ~ tokens def tokens: Parser[Any] = rep(token) //how to make this non-greedy? def token: Parser[Any] = "(\\s*)\\w+(\\s*)".r } When trying to match selectstatement against SELECT foo FROM bar , how do I prevent the selectclause from gobbling up the entire phrase due to the rep(token) in ~ tokens ? In other words, how do I

What are features of ANTLR that XText Does not provide?

Deadly 提交于 2019-12-01 02:20:53
I just came across very nice tool Xtext to create DSL as well as IDE for editing. I did some search on the web and found people saying it does not provide all the features of ANTLR. I am using ANTLR as my parser generator. I am not even sure what features of ANTLR I will need to write complete parser for my language but ANTLR is around for quite a long time and probably supports more features than Xtext. Can anyone please give some examples of what CANNOT be specified in a Xtext grammar? You cannot specify semantic predicates in an Xtext grammar. Furthermore it's not possible to include