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
1
vote
1 answer

Bug in a simple parser specification in F#

I wonder where the parser specification below went wrong. The parser aims to parse and evaluate an expression like 2+3*4 to 14. It is to be run with FsLexYacc. %{ %} %token CSTINT %token PLUS MINUS MUL %token LPAR RPAR %token EOF %left MINUS…
zell
  • 9,830
  • 10
  • 62
  • 115
1
vote
1 answer

Is it possible to use FsYacc parser developed for one language as part of parsing process for other language?

I'm implementing parsing and expression evaluation for two languages L1 and L2. Important thing is that L1 can be used as separate language or as a part of L2, and L2 contains only several keywords, which are absent in L1. I've done already Lexing…
Vitaliy
  • 2,744
  • 1
  • 24
  • 39
1
vote
1 answer

fsyacc: allowing operators to be defined in language

Does fsyacc have some way to deal with operators that are introduced at parse time? I'm trying to build a parser for Kaleidoscope which is a toy language used as an example for the LLVM tutorial. Kaleidoscope allows operators to be defined along…
Keith
  • 2,820
  • 5
  • 28
  • 39
1
vote
2 answers

Extending example grammar for Fsyacc with unary minus

I tried to extend the example grammar that comes as part of the "F# Parsed Language Starter" to support unary minus (for expressions like 2 * -5). I hit a block like Samsdram here Basically, I extended the header of the .fsy file to include…
Román
  • 1,943
  • 2
  • 18
  • 28
1
vote
1 answer

Error in example grammar for Fsyacc?

So I am trying to write a compiler in F# and have been looking at the Fslex and Fsyacc tools that come with the F# powerpack. There is a sample project that takes care of the external build tools that I have been trying to understand. It can be…
Samsdram
  • 1,615
  • 15
  • 18
1
vote
2 answers

Crazy errors with FsLex and FsYacc

I am trying to compile this project: http://ramon.org.il/Here.zip But I get a bunch of non-sense errors. They got text I am familiar with, but in the position there is nothing like that (like unexpected ')' at an empty row). Help me, please!
Ramon Snir
  • 7,520
  • 3
  • 43
  • 61
1
vote
1 answer

Using record types in FSYACC

In FSYACC it is common to have terminals that result in tuples. However, for convenience I want to use a record type instead. For example, if I have the following in my Abstract Syntax Tree (AbstractSyntaxTree.fsl): namespace FS module…
Flakker
  • 423
  • 5
  • 17
1
vote
1 answer

Parsing a sequence of expressions using yacc

I am trying to parse a sequence of expressions without delimiters in order to be able to parse ML/F# style function invocations: myfunc expr1 expr2 expr3 However, the sequence of expressions is giving me a list of shift/reduce conflicts. My guess…
Rune
  • 8,340
  • 3
  • 34
  • 47
0
votes
1 answer

FsYacc filename.targets

I'm trying to specify an output folder for the FsYacc and FsLex compilers. I can see that there are some variables "FsYaccOutputFolder" and "FsLexOutputFolder" given in the FsLexYacc.targets I do have not that much experience with .targets files,…
kam
  • 590
  • 2
  • 11
0
votes
1 answer

Given a lexer implemented in FsLexYacc, how do I get all of the tokens?

I have a lexer and parser implemented in FsLexYacc. To debug the lexer, I would like to print all of the tokens for a given string. Here is what I have so far: #load "../.paket/load/net5.0/FsLexYacc.Runtime.fsx" #load "./Domain.fs" #load…
sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
0
votes
1 answer

FsLexYacc compile errors?

I'm trying to setup a new project in F#. I'm using FsLexYacc as a tool, and last time i used it was when the Fsharp powerpack was 'in'. The documentation on the site are not that good. It also seems to me that there is a bug with the generic type…
kam
  • 590
  • 2
  • 11
0
votes
1 answer

Why 1*2+3 is parsed as 1*(2+3) even though operator precedence or associativity is not declared?

I use fsyacc (yacc for fsharp) to write a small parser. The grammar is something like Expr:= | INT { Cst $1 } | Expr PLUS Expr { Op("+", $1, $3) } | Expr TIMES Expr …
zell
  • 9,830
  • 10
  • 62
  • 115
0
votes
1 answer

FsLex FsYacc: How to create a language with a multi-line comment

I am playing around with FsLex and FsYacc, which is based off of ocamllex and ocamlyacc. What is the best way to define a comment in a language? Do I create a comment token in my lex file? There are a few complications to to comments that I cannot…
Phillip Scott Givens
  • 5,256
  • 4
  • 32
  • 54
0
votes
2 answers

F# 2.0 with Powerpack 2.0, fslex error 1

In namespace RSLispV3.RunTime: http://pastebin.com/XNb9qi11 LispParser.fsy: http://pastebin.com/pymF1Vvm LispLexer.fsl: http://pastebin.com/pfXdDuxs I got in MSBuild the PowerPacks targets, calling them from the .fsprog. When building with VS2008 I…
Ramon Snir
  • 7,520
  • 3
  • 43
  • 61
0
votes
1 answer

FsLexYacc : Tests/MiniProject "incorrect Import in .fsproj"

On github, FsLexYacc project has a test dir. I try to set up the simplest one ("LexAndYaccMiniProject"). I follow these steps : 1/ Create an F# console app named "LexAndYaccMiniProject" 2/ Install package ("PM > Install-Package FsLexYacc" from VS…
FZed
  • 520
  • 3
  • 10