uu-parsinglib

Cannot compute minimal length of a parser - uu-parsinglib in Haskell

China☆狼群 提交于 2020-01-02 04:42:08
问题 Lets see the code snippet: pSegmentBegin p i = pIndentExact i *> ((:) <$> p i <*> ((pEOL *> pSegment p i) <|> pure [])) if I change this code in my parser to: pSegmentBegin p i = do pIndentExact i ((:) <$> p i <*> ((pEOL *> pSegment p i) <|> pure [])) I've got an error: canot compute minmal length of a parser due to occurrence of a moadic bind, use addLength to override I thought the above parser should behave the same way. Why this error can occur? EDIT The above example is very simple (to

Cannot compute minimal length of a parser - uu-parsinglib in Haskell

旧巷老猫 提交于 2019-12-05 10:02:47
Lets see the code snippet: pSegmentBegin p i = pIndentExact i *> ((:) <$> p i <*> ((pEOL *> pSegment p i) <|> pure [])) if I change this code in my parser to: pSegmentBegin p i = do pIndentExact i ((:) <$> p i <*> ((pEOL *> pSegment p i) <|> pure [])) I've got an error: canot compute minmal length of a parser due to occurrence of a moadic bind, use addLength to override I thought the above parser should behave the same way. Why this error can occur? EDIT The above example is very simple (to simplify the question) and as noted below it is not necessary to use do notation here, but the real case

Combining lexer and parser in a parser combinator

放肆的年华 提交于 2019-12-01 06:30:28
I'm using uu-parsinglib , but I think the following question is parser combinator generic. Let's consider the following example: I've got a lexer with a combinator pLex , which produces a list of tokens (of type MyToken ). I now want to write a parser, which will consume the tokens and build an AST . What is the best way to connect the lexer and parser? Right now I have a lex function: lex s = parse ( (,) <$> pLex <*> pEnd) (createStr (LineColPos 0 0 0) s) Should I create a function parse p = ... ? If yes, how do I construct it to keep track of columns and lines from lexer? Or should I create

Combining lexer and parser in a parser combinator

柔情痞子 提交于 2019-12-01 05:27:38
问题 I'm using uu-parsinglib , but I think the following question is parser combinator generic. Let's consider the following example: I've got a lexer with a combinator pLex , which produces a list of tokens (of type MyToken ). I now want to write a parser, which will consume the tokens and build an AST . What is the best way to connect the lexer and parser? Right now I have a lex function: lex s = parse ( (,) <$> pLex <*> pEnd) (createStr (LineColPos 0 0 0) s) Should I create a function parse p =

Parsec or happy (with alex) or uu-parsinglib

我的未来我决定 提交于 2019-11-30 10:41:14
问题 I am going to write a parser of verilog (or vhdl) language and will do a lot of manipulations (sort of transformations) of the parsed data. I intend to parse really big files (full Verilog designs, as big as 10K lines) and I will ultimately support most of the Verilog. I don't mind typing but I don't want to rewrite any part of the code whenever I add support for some other rule. In Haskell, which library would you recommend? I know Haskell and have used Happy before (to play). I feel that

Parsec or happy (with alex) or uu-parsinglib

↘锁芯ラ 提交于 2019-11-29 21:50:13
I am going to write a parser of verilog (or vhdl) language and will do a lot of manipulations (sort of transformations) of the parsed data. I intend to parse really big files (full Verilog designs, as big as 10K lines) and I will ultimately support most of the Verilog. I don't mind typing but I don't want to rewrite any part of the code whenever I add support for some other rule. In Haskell, which library would you recommend? I know Haskell and have used Happy before (to play). I feel that there are possibilities in using Parsec for transforming the parsed string in the code (which is a great