[Ur] creating tags for sml code? - do you know a better way then augmenting the ocaml parser of exuberant ctags with some sml specific regexes?

Marc Weber marco-oweber at gmx.de
Mon Dec 20 22:43:04 EST 2010


I found that the default implementation of language SML in exuberant
ctags is very poor.

Look at this code:

    datatype kind' =
             KType
           | KArrow of kind * kind
           | KName
           | KRecord of kind
           | KUnit
           | KTuple of kind list
           | KWild

           | KFun of string * kind
           | KVar of string

only kind' will be indexed.

So I came up with this solution: I use the ocaml parser (which can find
stuff like EApp) adding regex so that datatypes, structures etc are
still found (because creating regex for those is easy)

If you put this into your ~/.ctags file it seems to work reasonable
well.

    --langmap=OCaml:.sml
    --regex-OCaml=/^[ \t]*datatype[ \t]+([A-Z'a-z0-9_]+)/\1/d,datatype/
    --regex-OCaml=/^[ \t]*and[ \t]+([A-Z'a-z0-9_]+)/\1/d,datatype/
    --regex-OCaml=/^[ \t]*withtype[ \t]+([A-Z'a-z0-9_]+)/\1/w,withtype/
    --regex-OCaml=/^[ \t]*structure[ \t]+([A-Z'a-z0-9_]+)/\1/s,structure/
    --regex-OCaml=/[ \t]*val[ \t]+([A-Z'a-z0-9_]+)/\1/v,val/
    --regex-OCaml=/^[ \t]*fun[ \t]+([A-Z'a-z0-9_]+)/\1/f,fun/
    --regex-OCaml=/^[ \t]*type[ \t]+([A-Z'a-z0-9_]+)/\1/t,type/

The only major drawback seems to be ocaml adding files as lower case
modules. eg compiler.sml will be added as tag "complier" instead of
"Compiler"

I'm still interested in whether you've found a better solution?

Maybe this is useful to you as well.

Marc Weber



More information about the Ur mailing list