Permalink
Browse files

lang_python: more highlight

  • Loading branch information...
1 parent 5bf3511 commit 5ae7bc347cb7dea9ec95c5aa71970d1c9311560c pad committed Nov 14, 2010
Showing with 15 additions and 3 deletions.
  1. +1 −1 commons/file_type.ml
  2. +13 −1 lang_python/analyze/highlight_python.ml
  3. +1 −1 lang_python/parsing/lexer_python.mll
@@ -182,7 +182,7 @@ let file_type_of_file2 file =
| "nw" | "web" -> Text e
| "org"
- | "md" | "rest"
+ | "md" | "rest" | "textile"
-> Text e
| "rtf" -> Text e
@@ -47,6 +47,12 @@ let fake_no_use2 = (NoInfoPlace, UniqueDef, MultiUse)
let lexer_based_tagger = true
+
+let builtin_functions = Common.hashset_of_list [
+ "isinstance";
+ "set";
+ "dict";
+]
(*****************************************************************************)
(* Code highlighter *)
(*****************************************************************************)
@@ -134,7 +140,11 @@ let visit_toplevel
| T.TIdent (s, ii1)::T.TOParen(ii2)::xs ->
if not (Hashtbl.mem already_tagged ii1) && lexer_based_tagger
- then tag ii1 (Function (Use2 fake_no_use2));
+ then
+ (if Hashtbl.mem builtin_functions s
+ then tag ii1 Builtin
+ else tag ii1 (Function (Use2 fake_no_use2))
+ );
aux_toks xs
| T.TIdent (s, ii1)::T.TDot ii2::T.TIdent (s3, ii3)::xs ->
@@ -161,10 +171,12 @@ let visit_toplevel
)
| T.TIdent (s, ii1)::xs ->
+ (*
if s =~ "[a-z]" then begin
if not (Hashtbl.mem already_tagged ii1) && lexer_based_tagger
then tag ii1 (Local (Use));
end;
+ *)
aux_toks xs
@@ -272,7 +272,7 @@ rule token = parse
and string_quote = parse
| "'" { "" }
- | [^ '\'' '\n']* { let s = tok lexbuf in s ^ string_quote lexbuf }
+ | [^ '\'' '\\' '\n']* { let s = tok lexbuf in s ^ string_quote lexbuf }
| escapeseq { let s = tok lexbuf in s ^ string_quote lexbuf }
| eof { pr2 "LEXER: end of file in string_quote"; "'"}

3 comments on commit 5ae7bc3

@JeffBarron

why do this to yourself?

@aryx
Contributor
aryx commented on 5ae7bc3 Aug 1, 2012

??

@JeffBarron

lol just being silly. I hadn't ran across ocaml code before this and thought yeesh what a nasty syntax before reading an article. feel free to delete comments or let me know if you need em deleted. I'm curious to see where this project goes with the history of hiphop.

Please sign in to comment.