HongboZhang avatar HongboZhang committed e345684

deep annotation support added

Comments (0)

Files changed (1)

camlp4/Camlp4/Struct/Lexer.mll

     Stack.iter (Format.eprintf "%a@." print_opt_char ) opt_char 
   end
   (* the trailing char after "$" *)    
-  let anti_char : char Stack.t = Stack.create ()
-  let show_anti_stack() = begin
-    Stack.iter (Format.eprintf "%c@." ) anti_char
-  end 
+  (* let anti_char : char Stack.t = Stack.create ()
+   * let show_anti_stack() = begin
+   *   Stack.iter (Format.eprintf "%c@." ) anti_char
+   * end  *)
   (* Error report *)
   module Error = struct
 
     | ( "#"  | "`"  | "'"  | ","  | "."  | ".." | ":"  | "::"
       | ":=" | ":>" | ";"  | ";;" | "_"
       | left_delimitor | right_delimitor ) as x  { SYMBOL x }
-    | '$' (symbolchar as p)
+    | ".$" 
         { if antiquots c
             (* $() is more beautiful but () are not symbol chars *)
-            then let () = Stack.push  with_curr_loc dollar (shift 2 c)
-            else parse (symbolchar_star ("$" ^ String.make 1 p)) c } 
+        then
+          with_curr_loc dollar (shift 2 c)
+        else parse (symbolchar_star ".$") c } 
     | ['~' '?' '!' '=' '<' '>' '|' '&' '@' '^' '+' '-' '*' '/' '%' '\\'] symbolchar *
                                                                 as x { SYMBOL x }
     | eof
     | _                                               { store_parse quotation c }
 
   and dollar c = parse
-    | '.'                                     { set_start_p c; ANTIQUOT("", "") }
+    | "$."                                     { set_start_p c; ANTIQUOT("", "") }
     | ('`'? (identchar+) as name) ':' 
-      { with_curr_loc (antiquot name) (shift (1 + String.length name) c)        }
-    | 
-    | _                                           { store_parse (antiquot "") c }
+      { with_curr_loc (antiquot name 0) (shift (1 + String.length name) c)        }
+    (*handle special case .$.$x$.$.*)
+    | ".$"                                     {store_parse (antiquot "" 1 ) c }  
 
-  and antiquot name c = parse
-    | '.'                      { set_start_p c; ANTIQUOT(name, buff_contents c) }
+    | _                                           { store_parse (antiquot "" 0) c }
+
+  and antiquot name depth c = parse
+    | "$."
+        { if depth = 0 then let () = set_start_p c in ANTIQUOT(name, buff_contents c)
+          else store_parse (antiquot name (depth - 1)) c  }
+    | ".$" {store_parse (antiquot name (depth + 1 )) c }
     | eof                                   { err Unterminated_antiquot (loc c) }
     | newline
-      { update_loc c None 1 false 0; store_parse (antiquot name) c              }
+      { update_loc c None 1 false 0; store_parse (antiquot name depth) c              }
     | '<' (':' ident)? ('@' locname)? '<' (symbolchar as p)?
-      { let () = Stack.push p opt_char
+      { let () = Stack.push p opt_char in
         let () = store c in
         let () = with_curr_loc quotation c in
-        parse (antiquot name) c }
-    | _                                         { store_parse (antiquot name) c }
+        parse (antiquot name depth) c }
+    | _                                         { store_parse (antiquot name depth) c }
 
   {
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.