Commit 871a4efa authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-06-25 12:15:47 by afrisch] Clean lexer global state in case of error

Original author: afrisch
Date: 2004-06-25 12:15:48+00:00
parent 7ad17eb3
......@@ -220,18 +220,42 @@ driver/librarian.cmx: types/builtin.cmx compile/compile.cmx \
misc/encodings.cmx runtime/eval.cmx types/ident.cmx compile/lambda.cmx \
parser/location.cmx parser/parser.cmx misc/serialize.cmx typing/typer.cmx \
types/types.cmx runtime/value.cmx driver/librarian.cmi
cdo2cmo/ml_types.cmo: types/types.cmi
cdo2cmo/ml_types.cmx: types/types.cmx
cdo2cmo/ml_cduce.cmo: types/atoms.cmi types/builtin_defs.cmi types/chars.cmi \
compile/compile.cmi misc/encodings.cmi types/ident.cmo \
types/intervals.cmi compile/lambda.cmo driver/librarian.cmi \
cdo2cmo/ml_types.cmo misc/ns.cmi types/sequence.cmi typing/typer.cmi \
types/types.cmi
cdo2cmo/ml_cduce.cmx: types/atoms.cmx types/builtin_defs.cmx types/chars.cmx \
compile/compile.cmx misc/encodings.cmx types/ident.cmx \
types/intervals.cmx compile/lambda.cmx driver/librarian.cmx \
cdo2cmo/ml_types.cmx misc/ns.cmx types/sequence.cmx typing/typer.cmx \
types/types.cmx
cdo2cmo/ml_ocaml.cmo: driver/librarian.cmi cdo2cmo/ml_types.cmo
cdo2cmo/ml_ocaml.cmx: driver/librarian.cmx cdo2cmo/ml_types.cmx
cdo2cmo/ml_checker.cmo: cdo2cmo/ml_cduce.cmo cdo2cmo/ml_ocaml.cmo \
cdo2cmo/ml_types.cmo
cdo2cmo/ml_checker.cmx: cdo2cmo/ml_cduce.cmx cdo2cmo/ml_ocaml.cmx \
cdo2cmo/ml_types.cmx
cdo2cmo/ml_generator.cmo: cdo2cmo/ml_cduce.cmo cdo2cmo/ml_ocaml.cmo \
cdo2cmo/ml_types.cmo
cdo2cmo/ml_generator.cmx: cdo2cmo/ml_cduce.cmx cdo2cmo/ml_ocaml.cmx \
cdo2cmo/ml_types.cmx
driver/cduce.cmo: parser/ast.cmo types/builtin.cmi compile/compile.cmi \
misc/encodings.cmi runtime/eval.cmi runtime/explain.cmi types/ident.cmo \
driver/librarian.cmi parser/location.cmi misc/ns.cmi parser/parser.cmi \
types/patterns.cmi types/sample.cmi schema/schema_common.cmi \
misc/state.cmi typing/typer.cmi types/types.cmi parser/ulexer.cmi \
runtime/value.cmi driver/cduce.cmi
driver/librarian.cmi parser/location.cmi cdo2cmo/ml_cduce.cmo \
cdo2cmo/ml_checker.cmo cdo2cmo/ml_generator.cmo cdo2cmo/ml_ocaml.cmo \
misc/ns.cmi parser/parser.cmi types/patterns.cmi types/sample.cmi \
schema/schema_common.cmi misc/state.cmi typing/typer.cmi types/types.cmi \
parser/ulexer.cmi runtime/value.cmi driver/cduce.cmi
driver/cduce.cmx: parser/ast.cmx types/builtin.cmx compile/compile.cmx \
misc/encodings.cmx runtime/eval.cmx runtime/explain.cmx types/ident.cmx \
driver/librarian.cmx parser/location.cmx misc/ns.cmx parser/parser.cmx \
types/patterns.cmx types/sample.cmx schema/schema_common.cmx \
misc/state.cmx typing/typer.cmx types/types.cmx parser/ulexer.cmx \
runtime/value.cmx driver/cduce.cmi
driver/librarian.cmx parser/location.cmx cdo2cmo/ml_cduce.cmx \
cdo2cmo/ml_checker.cmx cdo2cmo/ml_generator.cmx cdo2cmo/ml_ocaml.cmx \
misc/ns.cmx parser/parser.cmx types/patterns.cmx types/sample.cmx \
schema/schema_common.cmx misc/state.cmx typing/typer.cmx types/types.cmx \
parser/ulexer.cmx runtime/value.cmx driver/cduce.cmi
query/query.cmo: parser/ast.cmo types/atoms.cmi types/builtin_defs.cmi \
types/chars.cmi types/ident.cmo types/intervals.cmi parser/location.cmi \
parser/parser.cmi types/types.cmi query/query.cmi
......
......@@ -144,6 +144,12 @@ and string start double = lexer
let lexbuf = ref None
let last_tok = ref ("","")
let raise_clean e =
clear_buff ();
in_comment := false;
(* reinit encoding ? *)
raise e
let tok_func cs =
let lb = L.from_var_enc_stream enc cs in
(lexer ("#!" [^ '\n']* "\n")? -> ()) lb;
......@@ -153,11 +159,13 @@ let tok_func cs =
try token lb
with
| Ulexing.Error ->
raise (Error (Ulexing.lexeme_end lb, Ulexing.lexeme_end lb,
raise_clean (Error (Ulexing.lexeme_end lb, Ulexing.lexeme_end lb,
"Unexpected character"))
| Ulexing.InvalidCodepoint i ->
raise (Error (Ulexing.lexeme_end lb, Ulexing.lexeme_end lb,
"Code point invalid for the current encoding")) in
raise_clean (Error (Ulexing.lexeme_end lb, Ulexing.lexeme_end lb,
"Code point invalid for the current encoding"))
| e -> raise_clean e
in
last_tok := fst tok;
tok
in
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment