Questions tagged [ocamllex]

ocamllex is a Lexer generator for OCaml

ocamllex is the lexer generator for OCaml. It is based on lex (now better known as flex).

It is used within the OCaml compiler, and thus, it is installed by the official OCaml distribution. ocamllex is powerful and nicely integrated within OCaml.

For simple uses, a simple lexer generator is also available in the Genlex module of the standard library, and allows to lex files with a syntax similar to OCaml ( (..) for comments, same escape sequences in strings, etc.).

References:

See also:

94 questions
0
votes
1 answer

the generated file by the ocamllex

the theory says about lex tool (I read ocamllex) it will convert a collection of regular expressions into C (OCaml) code for a DFA (actually in a NFA and also NFA2DFA). The formal definition of a DFA M is a 5 tuple M = { Q, Sigma,…
dag
  • 288
  • 2
  • 10
0
votes
1 answer

How to write a three address code using ocamllex and ocamlyacc?

I was wondering how to write a three address code using ocamllex and ocamlyacc? I googled a lot about this, but I couldn't find anything using ocamlyacc. I have my parser and my lexer working(both using of course ocamlyacc and ocamllex) but now I…
tsukanomon
  • 1,220
  • 1
  • 19
  • 23
-1
votes
1 answer

Debug parser by printing useful information

I would like to parse a set of expressions, for instance:X[3], X[-3], XY[-2], X[4]Y[2], etc. In my parser.mly, index (which is inside []) is defined as follows: index: | INTEGER { $1 } | MINUS INTEGER { 0 - $2 } The token INTEGER, MINUS etc. are…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
-2
votes
1 answer

Ocaml syntax error : pattern expected in building zip fuction

I want to make fuction called zip so: zip [1;2;3;4] [5;6;7;8] would produce: [1;5;2;6;3;7;4;8] but I'm getting an error: line#4 h2::t2 make error syntax error : pattern expected What would be the correct syntax? let rec zip lst1 lst2 = match…
1 2 3 4 5 6
7