Questions tagged [alex]

A lexical analyser generator for Haskell

Alex is a tool for generating lexical analysers in Haskell, given a description of the tokens to be recognised in the form of regular expressions. It is similar to the tool lex or flex for C/C++. Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing.

Note: Alex is part of the Haskell Platform, thus when you install the platform you will automatically have a working Alex. The Haskell Platform is a single, standard Haskell development environment for everyone. It offers a set of blessed libraries and tools, to save you the task of picking and choosing which core Haskell libraries to use.

61 questions
0
votes
1 answer

Get token for any symbols in quotes in lexer

I want to parse any symbols in quotes. I can parse words this way. How should look regexp for any symbols? $alpha=[a-zA-Z] \"$alpha+\" { \s -> TText (pack s) }
Max Osad
  • 27
  • 5
0
votes
1 answer

Patter for byte when I got pattern for numbers in lexer

I have pattern for numbers in lexer $digit=0-9 $digit+ { \s -> TNum (readRational s) } I want to add another pattern for bytes. Bytes contain 2 symbols from diaposon 0 - f. Which pattern I should write for byte? Will it…
Max Osad
  • 27
  • 5
0
votes
0 answers

Cabal Build Producing Errors - Code Seems Fine Manually?

Throughout my development i've been manually running alex/happy to generate my parser files and then running ghci to test the code. This works fine and loads me into GHCI, but whenever I run cabal repl the program throws an error in my Parser.hs…
Sheldor
  • 11
  • 4
0
votes
1 answer

Happy Parse Error

I'm currently using the alex and happy lexer/parser generators to implement a parser for the Ethereum Smart contract language solidity. Currently I'm using a reduced grammar in order to simplify the initial development. I'm running into an error…
Sheldor
  • 11
  • 4
0
votes
2 answers

Alexa adding extra character to slot value

​I am trying to get user response with option of a b c d or e . I have configured a slot with these possible values and reading the slot in my nodejs. when a user responds with the option a, c,d,e are returned ok in intent.slots.Answer.value …
Kumar
  • 11
  • 1
0
votes
0 answers

How to have Alexa ask user if they'd like another, and rerun an intent?

I'm using STDLIB and Node.js to write an Alexa skill that delivers a random limerick. I want a flow like this: User: Ask LimerickKid for a limerick. Alexa skill fires, delivers limerick. Alexa: Would you like another? And then use the…
brianfit
  • 1,829
  • 1
  • 19
  • 34
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

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

Is there a way to put Haskell code before the token rules in an Alex source file?

Consider the following, working, Alex source file: { module Main (main) where } %wrapper "basic" tokens :- $white ; . { rule "!"} { type Token = String rule tok = \s -> tok main = do s <- getContents mapM_ print…
hugomg
  • 68,213
  • 24
  • 160
  • 246
0
votes
2 answers

Mongodb elemMatch alex bilbie library

i am using alex bilbie library for mongo db (https://github.com/alexbilbie/codeigniter-mongodb-library/tree/v2). I dont know how to form elemMatch query with this lib. I need to transform this to alexs lib. db.centers.find( { '_id':…
j6c
  • 39
  • 1
  • 8
-1
votes
1 answer

[af]?lex regular expression difference

I don't know how to do this, and I've found no good resources online for how to perform this operation[.] I'm trying to take an annotated EBNF production rule which is a difference between two regular expressions and turn it into a(n a| f?)lex…
-1
votes
1 answer

Tilde accent marks alex

I'm building a compiler in Haskell. I have problems parsing characters with tilde accent marks. I'm using alex 2.3.3. I can't find a solution. Please help.
Academia
  • 3,984
  • 6
  • 32
  • 49
-1
votes
1 answer

How do you install Alex on Haskell Platform?

I have Haskell Platform 8.2.2 installed on Windows. When I run ghci and type alex H.x after Prelude>, I get :3:6: error: Not in scope: `H.x' No module named `H' is imported. When I type just alex, I get :6:1:…
johnsmith
  • 515
  • 5
  • 12
-3
votes
2 answers

How to check if a regex has an even number of one character with only 2 characters total?

I want to be able to use a file containing only A's and B's and using only a regex be able to only allow sections with an even number of A's and either odd or even for B's. The A's can be separated by B's and don't have to be in sets of 2. Here are…