let regexp number = xml_digit+
+ (* ZACK: breaks unicode's binder followed by an ascii letter without blank *)
+(* let regexp ident_letter = xml_letter *)
+
+let regexp ident_letter = [ 'a' - 'z' 'A' - 'Z' ]
+
let regexp ident_decoration = '\'' | '!' | '?' | '`'
-let regexp ident_cont = xml_letter | xml_digit | '_'
-let regexp ident = xml_letter ident_cont* ident_decoration*
+let regexp ident_cont = ident_letter | xml_digit | '_'
+let regexp ident = ident_letter ident_cont* ident_decoration*
let regexp tex_token = '\\' ident
let regexp delim_begin = "\\["
let regexp delim_end = "\\]"
-let regexp keyword = '"' ident '"'
let regexp qkeyword = "'" ident "'"
let regexp implicit = '?'
+let regexp placeholder = '%'
let regexp meta = implicit number
let regexp csymbol = '\'' ident
let regexp meta_anonymous = "$_"
let regexp qstring = '"' [^ '"']* '"'
+let regexp begincomment = "(**" xml_blank
+let regexp endcomment = "*)"
+let regexp comment_char = [^'*'] | '*'[^')']
+let regexp note = "(*" ([^'*'] | "**") comment_char* "*)"
+
let level1_layouts =
[ "sub"; "sup";
"below"; "above";
(* (string, unit) Hashtbl.t, to exploit multiple bindings *)
let level2_ast_keywords = Hashtbl.create 23
let _ =
- (* TODO ZACK: keyword list almost cut and paste from cicTextualLexer2.ml, to
- * be reviewed *)
List.iter (fun k -> Hashtbl.add level2_ast_keywords k ())
- [ "Prop"; "Type"; "Set"; "let"; "rec"; "corec"; "match"; "with"; "in";
- "and"; "on" ]
+ [ "CProp"; "Prop"; "Type"; "Set"; "let"; "rec"; "corec"; "using"; "match";
+ "with"; "in"; "and"; "to"; "as"; "on"; "names" ]
let add_level2_ast_keyword k = Hashtbl.add level2_ast_keywords k ()
let remove_level2_ast_keyword k = Hashtbl.remove level2_ast_keywords k
("SYMBOL", Utf8Macro.expand macro)
with Utf8Macro.Macro_not_found _ -> "SYMBOL", Ulexing.utf8_lexeme lexbuf
-let keyword lexbuf = "KEYWORD", remove_quotes (Ulexing.utf8_lexeme lexbuf)
-
let remove_quotes s = String.sub s 1 (String.length s - 2)
let remove_left_quote s = String.sub s 1 (String.length s - 1)
let rec level2_ast_token = lexer
| xml_blank+ -> level2_ast_token lexbuf
| meta -> return lexbuf ("META", Ulexing.utf8_lexeme lexbuf)
- | implicit -> return lexbuf ("IMPLICIT", Ulexing.utf8_lexeme lexbuf)
+ | implicit -> return lexbuf ("IMPLICIT", "")
+ | placeholder -> return lexbuf ("PLACEHOLDER", "")
| ident ->
let lexeme = Ulexing.utf8_lexeme lexbuf in
if Hashtbl.mem level2_ast_keywords lexeme then
else
return lexbuf ("IDENT", lexeme)
| number -> return lexbuf ("NUMBER", Ulexing.utf8_lexeme lexbuf)
- | keyword -> return lexbuf (keyword lexbuf)
| tex_token -> return lexbuf (expand_macro lexbuf)
| uri -> return lexbuf ("URI", Ulexing.utf8_lexeme lexbuf)
| qstring ->
return lexbuf ("QSTRING", remove_quotes (Ulexing.utf8_lexeme lexbuf))
- | csymbol -> return lexbuf ("CSYMBOL", Ulexing.utf8_lexeme lexbuf)
+ | csymbol ->
+ return lexbuf ("CSYMBOL", remove_left_quote (Ulexing.utf8_lexeme lexbuf))
| "${" -> read_unparsed_group "UNPARSED_META" lexbuf
| "@{" -> read_unparsed_group "UNPARSED_AST" lexbuf
| '(' -> return lexbuf ("LPAREN", "")
return lexbuf ("UNPARSED_META",
remove_left_quote (Ulexing.utf8_lexeme lexbuf))
| meta_anonymous -> return lexbuf ("UNPARSED_META", "anonymous")
- | _ -> return lexbuf ("SYMBOL", Ulexing.utf8_lexeme lexbuf)
+ | note ->
+ let comment =
+ Ulexing.utf8_sub_lexeme lexbuf 2 (Ulexing.lexeme_length lexbuf - 4)
+ in
+ return lexbuf ("NOTE", comment)
+ | begincomment -> return lexbuf ("BEGINCOMMENT","")
+ | endcomment -> return lexbuf ("ENDCOMMENT","")
| eof -> return lexbuf ("EOI", "")
+ | _ -> return lexbuf ("SYMBOL", Ulexing.utf8_lexeme lexbuf)
let rec level1_pattern_token = lexer
| xml_blank+ -> level1_pattern_token lexbuf