Commit 63ca3393 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 1ecd2985
...@@ -220,18 +220,42 @@ driver/librarian.cmx: types/builtin.cmx compile/compile.cmx \ ...@@ -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 \ misc/encodings.cmx runtime/eval.cmx types/ident.cmx compile/lambda.cmx \
parser/location.cmx parser/parser.cmx misc/serialize.cmx typing/typer.cmx \ parser/location.cmx parser/parser.cmx misc/serialize.cmx typing/typer.cmx \
types/types.cmx runtime/value.cmx driver/librarian.cmi 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 \ driver/cduce.cmo: parser/ast.cmo types/builtin.cmi compile/compile.cmi \
misc/encodings.cmi runtime/eval.cmi runtime/explain.cmi types/ident.cmo \ misc/encodings.cmi runtime/eval.cmi runtime/explain.cmi types/ident.cmo \
driver/librarian.cmi parser/location.cmi misc/ns.cmi parser/parser.cmi \ driver/librarian.cmi parser/location.cmi cdo2cmo/ml_cduce.cmo \
types/patterns.cmi types/sample.cmi schema/schema_common.cmi \ cdo2cmo/ml_checker.cmo cdo2cmo/ml_generator.cmo cdo2cmo/ml_ocaml.cmo \
misc/state.cmi typing/typer.cmi types/types.cmi parser/ulexer.cmi \ misc/ns.cmi parser/parser.cmi types/patterns.cmi types/sample.cmi \
runtime/value.cmi driver/cduce.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 \ driver/cduce.cmx: parser/ast.cmx types/builtin.cmx compile/compile.cmx \
misc/encodings.cmx runtime/eval.cmx runtime/explain.cmx types/ident.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 \ driver/librarian.cmx parser/location.cmx cdo2cmo/ml_cduce.cmx \
types/patterns.cmx types/sample.cmx schema/schema_common.cmx \ cdo2cmo/ml_checker.cmx cdo2cmo/ml_generator.cmx cdo2cmo/ml_ocaml.cmx \
misc/state.cmx typing/typer.cmx types/types.cmx parser/ulexer.cmx \ misc/ns.cmx parser/parser.cmx types/patterns.cmx types/sample.cmx \
runtime/value.cmx driver/cduce.cmi 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 \ 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 \ types/chars.cmi types/ident.cmo types/intervals.cmi parser/location.cmi \
parser/parser.cmi types/types.cmi query/query.cmi parser/parser.cmi types/types.cmi query/query.cmi
......
...@@ -144,6 +144,12 @@ and string start double = lexer ...@@ -144,6 +144,12 @@ and string start double = lexer
let lexbuf = ref None let lexbuf = ref None
let last_tok = ref ("","") let last_tok = ref ("","")
let raise_clean e =
clear_buff ();
in_comment := false;
(* reinit encoding ? *)
raise e
let tok_func cs = let tok_func cs =
let lb = L.from_var_enc_stream enc cs in let lb = L.from_var_enc_stream enc cs in
(lexer ("#!" [^ '\n']* "\n")? -> ()) lb; (lexer ("#!" [^ '\n']* "\n")? -> ()) lb;
...@@ -153,11 +159,13 @@ let tok_func cs = ...@@ -153,11 +159,13 @@ let tok_func cs =
try token lb try token lb
with with
| Ulexing.Error -> | 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")) "Unexpected character"))
| Ulexing.InvalidCodepoint i -> | Ulexing.InvalidCodepoint i ->
raise (Error (Ulexing.lexeme_end lb, Ulexing.lexeme_end lb, raise_clean (Error (Ulexing.lexeme_end lb, Ulexing.lexeme_end lb,
"Code point invalid for the current encoding")) in "Code point invalid for the current encoding"))
| e -> raise_clean e
in
last_tok := fst tok; last_tok := fst tok;
tok tok
in 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