Questions tagged [happy]

Happy is a YACC-like parse generator for Haskell

Happy is a like parse generator for the programming language.

108 questions
0
votes
1 answer

Parsing with parenthesis and different types of expressions

I'm currently using happy to parse a language, but I don't think the parser is relevant, except to say it's an LALR parser. Here's a small excerpt from the grammar: ArithExpr -> ArithExpr + ArithExpr ArithExpr -> ( ArithExpr ) ArithExpr ->…
Clinton
  • 22,361
  • 15
  • 67
  • 163
0
votes
1 answer

Specify to Stack which version of Happy to use

I'm running up against a bug in the latest version of Happy (1.19.5). How do I tell stack to go look for an even newer version of Happy (1.19.6) found only at the git repo? Right now, I'm letting stack manage everything; the only reference to Happy…
Alec
  • 31,829
  • 7
  • 67
  • 114
0
votes
1 answer

How to remove commas and parenthesis from function calls

In a functional language compiler written using the happy parser, which is a quite similar with yacc/bison, I implemented lists and with lists some core functions map, concat and filter, using the following rules: Exp: ... | concat '(' Exp ',' Exp…
fotanus
  • 19,618
  • 13
  • 77
  • 111
0
votes
2 answers

syntax happy parser meaning

I have this grammar section in a happy parser, given on the Happy official site, but I need some deeper explanation of the meaning of the rules in brackets. Here is the token definition %token let { TokenLet } in …
badvi93d
  • 133
  • 9
0
votes
1 answer

Haskell Happy parser error mismatching types and infinite type

Writing a Oberon-like language parser, I'm having troubles compiling the parser after I've updated it to be able to define more procedures on the same level, and not only nested one inside the other. This is my lexer: { module Lexer…
zeb
  • 1,105
  • 2
  • 9
  • 32
0
votes
2 answers

Haskell Happy parser not going further

I'm implementing a parser for a language similar to Oberon. I've successfully written the lexer using Alex since I can see that the list of tokens returned by the lexer is correct. When I give the tokens list to the parser, it stops at the first…
zeb
  • 1,105
  • 2
  • 9
  • 32
0
votes
0 answers

Happy precedence function definition and variable

I have been struggling to remove all s/r conflicts from my parser today. I managed to remove all of them but a single one. The syntax of my language should be haskell-like. And instead of a main, I have a top level expression which is the…
Christophe De Troyer
  • 2,852
  • 3
  • 30
  • 47
0
votes
1 answer

Where does "templates/wrappers.hs" live, in a Happy project?

I'm trying to make a parser using Alex with Happy. I'm following the instructions from this post, but having trouble. I'm trying to track down the source of the following type error: templates/wrappers.hs:234:9: Couldn't match type ‘Token’ with…
Patrick Collins
  • 10,306
  • 5
  • 30
  • 69
0
votes
1 answer

Parsing complex files with Parsec

I would like to parse files with several sequences of data (same number of column, same content, ...) with Haskell. My data sequences will be delimited by keywords before and after. BEGIN 1 882 2 809 3 435 4 197 5 229 6 …
JeanJouX
  • 2,555
  • 1
  • 25
  • 37
0
votes
1 answer

How to define association on rule without tokens?

I have the following minimized grammar Exp : let var '=' Exp in Exp end { App (Fn $2 $6) $4 } | Exp Exp { App $1 $2 } | Exp OpCode Exp { Op $1 Add $3…
fotanus
  • 19,618
  • 13
  • 77
  • 111
0
votes
1 answer

Data type mismatch with Haskell parser generator - Happy

I have been dealing with this problem for a couple days and I'm out of ideas, hopefully you can help me: My token list is the following: %Token var {TokenVariableDeclaration} varId {TokenVar $$} -- Strings like "x", "n" or "m" int …
Daniel Zendejas
  • 466
  • 3
  • 14
0
votes
1 answer

Did I install cabal correctly?

Hi I've just updated cabal to the latest version by the command cabal update and cabal install cabal-install Then it returns Installed cabal-install-1.22.2.0 Updating documentation index /MyPath I want to use alex and happy. Sorry I'm very new…
Yiyue Wang
  • 152
  • 1
  • 12
0
votes
1 answer

How do I properly format happy when dealing with robust AST declarations?

I am trying to create a lexxer and parser for a language and I'm having difficulty understanding the exact syntax when it comes to some more "robust" abstract syntax tree definitions. The issue in question is : fun_declaration : FUN ID param_list…
Aserian
  • 1,047
  • 1
  • 15
  • 31
0
votes
1 answer

GHC incompatibility installing haskell-src-exts via cabal

I'm running into a compatibility problem trying to cabal install agda using GHC 7.8.3 and Cabal 1.16.0.2, on Ubuntu 14.04. The problem appears to be with haskell-src-exts-1.15.0.1, which Agda requires. Compiling that library runs into the following…
Roly
  • 2,126
  • 2
  • 20
  • 34
0
votes
1 answer

GLR_Lib.hs: Could not find module 'System'

I am trying to generate a GLR parser from happy, but I am getting errors once the files are generated. Here is an example, ABC.y , so it's clear what I am trying: { module Main where } %name ps1 s1 %tokentype { ABC } %error { parseError } %token a…
Jonathan Gallagher
  • 2,115
  • 2
  • 17
  • 31