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…
I'm learning to use Alex and Happy to write a small compiler. I want to maintain line and column information for my AST nodes so that I can provide meaningful error messages to the user. To illustrate how I plan to do it, I wrote a small example…
I've trying to do cabal install hoogle but there is a hickup with the haskell-src-exts-1.13.5 dependency:
Configuring haskell-src-exts-1.13.5...
setup: The program happy version >=1.17 is required but it could not be found.
When I try to do cabal…
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…
As part of my compiler, I need alex and happy to run as part of my build process. How does Stack support this scenario?
Bonus: how can I register alex and happy as compile-time dependencies?
I'm writing a compiler for a class I'm taking. The class isn't specifically Haskell but I'm using Haskell to write my compiler and interpreter. I have a cabal package setup to hopefully make it easy for my prof to run/compile.
I have happy and alex…
I'm trying to learn using Alex + Happy to build parser, in particular I'm interested in learning to use the monad wrapper of Alex. I have already looked at the documentation of Alex and Happy but I they are both, for me, really lacking any useful…
I am using Happy to generate a parser.
I have found that when I give it tokens which match part of the grammar at a lower level than the top level (such as giving it an expression on it's own, that isn't part of a statement), I get an "Internal…
I'm using happyJS and use the regex underneath for phone validation
phone: function (val) {
return /^(?:[0-9]+$)/.test(val);
}
However this ONLY allows numbers. I want the user to be able to enter spaces as well like
238 238 45383
Any…
The source tree for happy contains AttrGrammarParser.ly and Parser.ly and the source tree for alex contains Scan.x. Yet, as far as I can tell in order to compile happy, we need to transform the .ly files into .lhs files using... happy, and in order…
When creating either a Lexer.x or a Parser.y parser using the Alex lexer generator or the Happy parser generator, compiling those into Haskell files, and compiling those into object files, by default this will generate the following "warnings":
$…
I have a grammar that, depending on the order of productions, happy reports 3 reduce/reduce conflicts or none. The minimal example I can find is:
%tokentype {Token}
%token
int { Int }
'-' { Neg }
both { Both }
%nonassoc…
I have two snippets of Happy code here, one that uses normal precedence rules, and one that uses context-dependent precedence rules (both of which are described here).
Normal:
%left '+'
%left '*'
%%
Exp :: { Exp }
: Exp '+' Exp { Plus $1 $3 }
…
I've been trying to get happy to install correctly for the past couple days, and while I found it challenging to get cabal install happy to not just error (by installing happy-1.19 with apt-get and adding /opt/happy/1.19.3/bin to PATH), now it runs…
I'm building a parser with Happy and noticed this is the online documentation:
Like yacc, we include %% here, for no real reason.
%%
There must be a reason though, even if it's trivial. Does anyone know what it is?