Search code examples
visual-studio-2010msbuildf#fsyacc

fsyacc errors when building in Visual Studio


I'm using fsyacc within Visual Studio (using the Parsed Language Starter template), but the build output doesn't show the line/column where the error occured (only: fsyacc exited with code 1). I have to build from the command prompt to get this information, somewhat negating the benefit of VS integration.

Is there a way to show this in the output window?

EDIT

Here are some examples of errors that aren't shown in the output window.

Parser.fsy(74,4): error: parse error

and

building tables
FSYACC: error FSY000: NonTerminal 'query' has no productions

Here's success output that would be nice to see also:

building tables
computing first function...time: 00:00:00.1318603
building kernels...time: 00:00:00.1027372
building kernel table...time: 00:00:00.0533044
computing lookahead relations.............................
..............time: 00:00:00.0517415
building lookahead table...time: 00:00:00.0207993
building action table...state 29: shift/reduce error on AS
state 49: shift/reduce error on OR
state 49: shift/reduce error on AND
...
time: 00:00:00.1457792
building goto table...time: 00:00:00.0035636
returning tables.
39 shift/reduce conflicts
62 states
11 nonterminals
41 terminals
46 productions
#rows in action table: 62

Solution

  • Instead of using Parsed Language Starter template, I build parser/lexer by using Pre-build event in Build Events from VS Project Properties:

    fslex "$(ProjectDir)Lexer.fsl"
    fsyacc --module Grammar "$(ProjectDir)Grammar.fsy"
    

    It is not very desirable since I have to set fsyacc/fslex in Path environment variable. Whenever I don't want to rebuild parser/lexer, I have to comment out the following part in fsproj file:

    <PropertyGroup>
      <PreBuildEvent>fslex "$(ProjectDir)Lexer.fsl"
                     fsyacc --module Grammar "$(ProjectDir)Grammar.fsy"
      </PreBuildEvent>
    </PropertyGroup>
    

    However, the winning point is clear. We have all messages including errors and success output in stdout which is convenient for debugging.