Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
duckpilot committed Aug 13, 2010
1 parent 956289d commit 7b70648
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
33 changes: 12 additions & 21 deletions _code/camlp4-custom-lexers/jq_lexer.ml
Expand Up @@ -12,11 +12,11 @@ end
let _ = let module M = Camlp4.ErrorHandler.Register(Error) in ()

type token =
| KEYWORD of string
| NUMBER of string
| STRING of string
| ANTIQUOT of string * string
| EOI
| KEYWORD of string
| NUMBER of string
| STRING of string
| ANTIQUOT of string * string
| EOI

module Token =
struct
Expand Down Expand Up @@ -45,26 +45,17 @@ struct
function
| KEYWORD s | NUMBER s | STRING s -> s
| tok ->
invalid_arg ("Cannot extract a string from this token: "^
to_string tok)
invalid_arg
("Cannot extract a string from this token: " ^
to_string tok)

module Filter =
struct
type token_filter = (t, Loc.t) Camlp4.Sig.stream_filter

type t = {
is_kwd : string -> bool;
mutable filter : token_filter
}

let mk is_kwd = {
is_kwd = is_kwd;
filter = (fun s -> s)
}

let filter x strm = x.filter strm
let define_filter x f = x.filter <- f x.filter

type t = unit
let mk _ = ()
let filter _ strm = strm
let define_filter _ _ = ()
let keyword_added _ _ _ = ()
let keyword_removed _ _ = ()
end
Expand Down
4 changes: 1 addition & 3 deletions _code/camlp4-custom-lexers/jq_quotations.ml
Expand Up @@ -36,12 +36,10 @@ object
| p -> super#patt p
end

open Jq_lexer (* so Jq_lexer.EOI is in scope, not Camlp4.PreCast.Token.EOI *)

let json_eoi = Jq_parser.Gram.Entry.mk "json_eoi"

EXTEND Jq_parser.Gram
json_eoi: [[ x = Jq_parser.json; EOI -> x ]];
json_eoi: [[ x = Jq_parser.json; `Jq_lexer.EOI -> x ]];
END;;

let parse_quot_string loc s =
Expand Down

0 comments on commit 7b70648

Please sign in to comment.