Skip to content

Commit

Permalink
Merge pull request #228 from teo-tsirpanis/fix-no-header
Browse files Browse the repository at this point in the history
Fix compile errors in fsyacc's output if there is no header in the input file.
  • Loading branch information
nojaf authored Dec 23, 2024
2 parents e8a4481 + 84fba2c commit 4500cbe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/FsYacc.Core/fsyaccdriver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,12 @@ type Writer(outputFileName, outputFileInterface) =
member x.WriteUInt16(i: int) = fprintf os "%dus;" i

member x.WriteCode(code, pos) =
x.WriteLine "# %d \"%s\"" pos.pos_lnum pos.pos_fname
x.WriteLine "%s" code
let codeLines = code.Replace("\r", "").Split([| '\n' |]).Length
outputLineCount <- outputLineCount + codeLines
x.WriteLine "# %d \"%s\"" outputLineCount outputFileName
if code <> "" then
x.WriteLine "# %d \"%s\"" pos.pos_lnum pos.pos_fname
x.WriteLine "%s" code
let codeLines = code.Replace("\r", "").Split([| '\n' |]).Length
outputLineCount <- outputLineCount + codeLines
x.WriteLine "# %d \"%s\"" outputLineCount outputFileName

member x.OutputLineCount = outputLineCount

Expand Down
7 changes: 1 addition & 6 deletions tests/LexAndYaccMiniProject/Parser.fsy
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
%{


%}

// The start token becomes a parser function in the compiled code:
// The start token becomes a parser function in the compiled code:
%start start

// Regular tokens
Expand Down

0 comments on commit 4500cbe

Please sign in to comment.