Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ let main () =
let module Code =
(val match !output_format with
| ".ml" -> (module Cpspg.CodeGenMl.Make (Settings) (Grammar) (Automaton))
| ".fram" -> (module Cpspg.CodeGenFram.Make (Settings) (Grammar) (Automaton))
| ".dot" -> (module Cpspg.CodeGenDot.Make (Settings) (Grammar) (Automaton))
| _ -> failwith "Unknown output format"
: Cpspg.Types.Code)
Expand Down
28 changes: 28 additions & 0 deletions framtools/Parsing.fram
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{# This file should be placed in the same directory as the generated
parser #}

pub data Pos = Pos of
{ fname : String
, lnum : Int
, bol : Int
, cnum : Int }

pub let dummyPos = Pos {fname = "", lnum = 0, bol = 0, cnum = 0-1}

pub data Lex E Tok = Lex of
{ token : Unit ->[E] Tok
, startPos : Unit ->[E] Pos
, curPos : Unit -> [E] Pos }

pub method token {E, Tok} (Lex {token} : Lex E Tok) = token
pub method startPos {E, Tok} (Lex {startPos} : Lex E Tok) = startPos
pub method curPos {E, Tok} (Lex {curPos} : Lex E Tok) = curPos

pub data Error E = Error of ({type X} -> String ->[E] X)
pub method parseError {E} (Error f : Error E) = f

{## Error-reporting function. Use this function to report errors
in semantic actions. If an error is reported, the result
returned by the parser will be the passed string wrapped in
a `Left` constructor. ##}
pub let error {E, ~error : Error E} s = ~error.parseError s
Loading