Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Commit

Permalink
Generate user-defined code only if defined.
Browse files Browse the repository at this point in the history
  • Loading branch information
gsvgit committed Oct 17, 2012
1 parent d583341 commit f299680
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/FsLex/fslex.fs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ let main() =

if (!light = Some(false)) || (!light = None && (Path.HasExtension(output) && Path.GetExtension(output) = ".ml")) then
cfprintfn os "#light \"off\"";

let printLinesIfCodeDefined (code,pos:Position) =
if pos <> Position.Empty // If bottom code is unspecified, then position is empty.
then
cfprintfn os "# %d \"%s\"" pos.Line pos.FileName;
cfprintfn os "%s" code;

let (code,pos) = spec.TopCode
cfprintfn os "# %d \"%s\"" pos.Line pos.FileName;
cfprintfn os "%s" code;
printLinesIfCodeDefined spec.TopCode
let code = fst spec.TopCode
lineCount := !lineCount + code.Replace("\r","").Split([| '\n' |]).Length;
cfprintfn os "# %d \"%s\"" !lineCount output;

Expand Down Expand Up @@ -206,10 +211,10 @@ let main() =
cfprintfn os " )")
cfprintfn os " | _ -> failwith \"%s\"" ident

let (code,pos) = spec.BottomCode

cfprintfn os "";
cfprintfn os "# %d \"%s\"" pos.Line pos.FileName;
cfprintfn os "%s" code;
printLinesIfCodeDefined spec.BottomCode
cfprintfn os "# 3000000 \"%s\"" output;

with e ->
Expand Down

0 comments on commit f299680

Please sign in to comment.