Questions tagged [fsyacc]

Fsyacc is a F# version of yacc, a program generates a parser (the part of a compiler that tries to make syntactic sense of the source code) based on an analytic grammar written in a notation similar to BNF.

Fsyacc is a F# version of yacc, a program generates a parser (the part of a compiler that tries to make syntactic sense of the source code) based on an analytic grammar written in a notation similar to BNF.

The parser generated by yacc requires a lexical analyzer, which is fslex in the case of fsyacc.

Fsyacc/fslex is shipped as a part of F# PowerPack. For detailed documentation, please visit http://fsharppowerpack.codeplex.com/wikipage?title=FsYacc

See also:

46 questions
37
votes
1 answer

Lexing and parsing concurrently in F#

Is there an easy way to get lexing and parsing to run concurrently when using fslex and fsyacc?
J D
  • 48,105
  • 13
  • 171
  • 274
10
votes
3 answers

F# fslex fsyacc mature for production code?

After reading a 2 year old webpage really ripping fslex/fsyacc, buggy, slow, stupid etc. compared to their OCamel counterparts i wonder what would be ones best bet for lexing parsing needs? Ive used ANTLR before with C# bindings but am currently in…
Jeps
  • 123
  • 2
  • 5
9
votes
1 answer

How to handle errors during parsing in F#

I'm using fslex/fsyacc utilities for my F# Lexer and Parser. If input text has incorrect syntax it is necessary to know place where it happens. It is possible to determine incorrect lexeme (token) in Lexer and throw an exception if it was used…
Vitaliy
  • 2,744
  • 1
  • 24
  • 39
8
votes
2 answers

What is the difference between lex/yacc and fslex/fsyacc?

I'm learning F# because I'd like to write a lexer and parser. I have a tiny bit of experience with this sort of processing but really need to learn it properly as well as F#. When learning the lexing/parsing functionality of F#, is studying lex and…
Alex Angas
  • 59,219
  • 41
  • 137
  • 210
6
votes
4 answers

F# pattern matching: how to match a set of possible types that share the same parameters?

I'm new to F# and not quite familiar with the whole pattern matching idea. I tried to search for a better solution to my problem but I fear I can't even express the problem properly – I hope the question title is at least somewhat accurate. What I…
enzi
  • 4,057
  • 3
  • 35
  • 53
5
votes
3 answers

Using FsLex/Yacc in Vs2013

I'm trying to resurrect an old f# parser project I had working in vs 2008 to work with vs 2013. It uses FsLexYacc. I got it building ok by using a prebuild step as thus: fslex --unicode "$(ProjectDir)XpathLexer.fsl" fsyacc --module XpathParser…
stephensong
  • 277
  • 1
  • 12
4
votes
3 answers

How to capture a string without quote characters

I'm trying to capture quoted strings without the quotes. I have this terminal %token STRING and this production constant: | QUOTE STRING QUOTE { String($2) } along with these lexer rules | '\'' { QUOTE } | [^ '\'']* { STRING…
Daniel
  • 47,404
  • 11
  • 101
  • 179
4
votes
1 answer

Meaningful errors during parsing with FSyacc

I'm using fsyacc/fslex from F# Power Pack to parse some source code. To detect errors I use the following code: use inputChannel = new StreamReader(File.OpenRead tempFileName) let lexbuf = Lexing.LexBuffer<_>.FromTextReader inputChannel let ast =…
Evgeny Gavrin
  • 7,627
  • 1
  • 22
  • 27
4
votes
3 answers

What to choose fsyacc/fslex or FParsec?

I need to parse simple DSL language like the following: import "library.txt" def main(int param1, bool param2) { var a = f4(param1); // or var d = f1(f2(f3(f4(param1)))); var b = f3(a); var c = f2(b); var d =…
Evgeny Gavrin
  • 7,627
  • 1
  • 22
  • 27
4
votes
1 answer

Fsyacc: an item with the same key has been added

I'm starting to play with Fslex/Fsyacc. When trying to generate the parser using this input Parser.fsy: %{ open Ast %} // The start token becomes a parser function in the compiled code: %start start // These are the terminal tokens of the grammar…
Román
  • 1,943
  • 2
  • 18
  • 28
4
votes
4 answers

Is it possible to define types that depend on each other and are defined in separated files?

I am trying to implement a library with extended parsing capabilities. I decided that I will use fsyacc because I knew it from the university. Unfortunately I encountered following problem. I defined a class for the head of my grammar (Head) and…
StanislawSwierc
  • 2,571
  • 17
  • 23
3
votes
1 answer

Getting FS0035 => Construct is deprecated

In a fsyacc based project, I have this line: type 'a cucomment = string This is the full error description I'm getting: CALast.fs(117,9): error FS0035: This construct is deprecated: This type abbreviation has one or more declared type…
pietervp
  • 225
  • 1
  • 7
3
votes
1 answer

Are parsers generated by FSYacc thread safe?

If I generate a parser using FSYacc will it be thread safe? The only reason I ask is because the functions Parsing.rhs_start_pos and Parsing.symbol_end_pos don't appear to have any state passed into them, which would lead me to assume that they are…
Jake
  • 3,427
  • 2
  • 28
  • 23
3
votes
2 answers

What is the fsyacc equivalent for the following ocamlyacc code?

I'm working on a toy compiler using F#, i.e., the combo of FsLex and FsYacc. To get familiar with them, I've read the Lexer/Parser chapter of Expert F# (v2) book (a good book btw). Right now, I've half way through the well-recommended ocamlyacc…
Cygwin98
  • 510
  • 5
  • 13
3
votes
2 answers

Representing optional syntax and repetition with OcamlYacc / FsYacc

I'm trying to build up some skills in lexing/parsing grammars. I'm looking back on a simple parser I wrote for SQL, and I'm not altogether happy with it -- it seems like there should have been an easier way to write the parser. SQL tripped me up…
Juliet
  • 80,494
  • 45
  • 196
  • 228
1
2 3 4