Questions tagged [happy]

Happy is a YACC-like parse generator for Haskell

Happy is a like parse generator for the programming language.

108 questions
2
votes
1 answer

Reference variable in quasiquoted LLVM

How do you pass a variable into a quasiquoted section? I'm using llvm-quote-general and would like to pass a Type into an instruction I'm building with the quasiquoter. I can build an instruction from just text: alloci64 :: Instruction alloci64 =…
Cirdec
  • 24,019
  • 2
  • 50
  • 100
2
votes
2 answers

Parsing function application with Happy

How would I parse something like f x y Into APPLY (APPLY f x) y using Happy? Right now I have a rule that says %left APP Expr : Expr Expr %prec APP { APPLY $1 $2 } But that parses the above as APPLY f (APPLY x y)
spacepotato
  • 173
  • 7
2
votes
1 answer

Possible bug in Happy?

I am writing a parser using Happy/Alex, and because the grammar I am parsing isn't entirely context free, I have need to get a hold of the lookahead token. The Happy documentation suggests that when using a threaded lexer, this can be done with…
John G
  • 269
  • 2
  • 9
2
votes
1 answer

Happy resolution of an error

In Regular Expressions, I can write: a(.)*b And this will match the entire string in, for example acdabb I try to simulate this with a token stream in Happy. t : a wildcard b wildcard : {- empty -} | wild wildcard wild : a | b | c | d |…
Jonathan Gallagher
  • 2,115
  • 2
  • 17
  • 31
2
votes
1 answer

What is a Grammar Rule (in Parsing)?

I am trying to write an interpreter but am having difficulty understanding the theoretical underpinnings of the process. I understand that the first part is to write a lexer which splits the string up into a list of valid tokens and then a parser is…
Anko
  • 87
  • 1
  • 1
  • 9
2
votes
1 answer

noob wants make a parser for a small language

I want make a parser in happy for the let-in-expression language. For example, i want parse the following string: let x = 4 in x*x At the university we study attribute grammars, and i want use this tricks to calculate directly the value of the…
optimusfrenk
  • 1,271
  • 2
  • 16
  • 34
2
votes
1 answer

How to Lex, Parse, and Serialize-to-XML Email Messages using Alex and Happy

I am working toward being able to input any email message and output an equivalent XML encoding. I am starting small, with one of the email headers -- the "From Header" Here is an example of a From Header: From: John Doe I want it…
Roger Costello
  • 3,007
  • 1
  • 22
  • 43
2
votes
1 answer

Haskell - Happy, math expressions and variables parser

I'm working on a Happy math expressions and variables parser. The problem is that I don't know how to save the value for a variable and use it later. Any ideas? This is how I recognize expressions and variables assignment: genExp : exp …
John Smith
  • 1,276
  • 4
  • 17
  • 35
2
votes
2 answers

Shift/Reduce conflicts in a propositional logic parser in Happy

I'm making a simple propositional logic parser on happy based on this BNF definition of the propositional logic grammar, this is my code { module FNC where import Data.Char import System.IO } -- Parser name, token types and error function…
2
votes
2 answers

Shift reduce conflicts in happy grammar

Hello good programmers, I have built following grammar in happy (haskell): P : program C {Prog $2} E : int {Num $1} | ident {Id $1} | true {BoolConst True} | false {BoolConst…
2
votes
4 answers

How to make a Syntax Highlighting for Java in Haskell?

Soon enough I will be forced to present a project in Haskell that is supposed to make a Java syntax highlighting. I did some research and I found out that Happy could be a solution( since is a yacc-like parser). Also there were mentioned Bison and…
Antonio
  • 35
  • 4
2
votes
1 answer

shift/reduce conflict in Happy

How can I make correct rules for parsing if-then[-else] case? Here is some grammar: { module TestGram (tparse) where } %tokentype { String } %token one { "1" } if { "if" } then { "then" } else { "else" …
user1374768
  • 288
  • 2
  • 11
1
vote
2 answers

How do I match a Regular Expression in a Happy parser?

I'm writing a JavaScript parser with Happy and I need to match a regular expression. I don't want to fully parse the regex, just store it as a string. The relevant part of my AST looks like this: data PrimaryExpr -- | Literal integer =…
Nick Brunt
  • 9,533
  • 10
  • 54
  • 83
1
vote
0 answers

Puzzling error message in Happy parser

I'm building a JavaScript parser in Haskell using Happy and I'm running into an error message that, no matter how hard I try, I can't debug. I can't really post all the code here as it is thousands of lines long. I'll try to post the relevant bits…
Nick Brunt
  • 9,533
  • 10
  • 54
  • 83
1
vote
0 answers

What is wrong with my "token type" in Happy?

I am writing a simple arithmetic expression parser in the Haskell platform's Happy. The Happy tutorial (labeled "Documentation") from the Haskell site implements a similar grammar to what I need. The difference is that I want to include floating…
nau5ea
  • 13
  • 4