1 """
   2   MoinMoin - Ocaml Source Parser
   3 
   4   Copyright: 2006 by Jakub Piotr Nowak <jakub.piotr.nowak@gmail.com>
   5   License: GNU GPL
   6 """
   7 from MoinMoin.util.ParserBase import ParserBase
   8 
   9 Dependencies = []
  10 
  11 class Parser(ParserBase):
  12   parsename = "ColorizedOcaml"
  13   extensions = ['.mli', '.mly', '.ml']
  14   Dependencies = []
  15 
  16   def setupRules(self):
  17     ParserBase.setupRules(self)
  18 
  19     self.addRulePair("Comment", "\([*]", "[*]\)")
  20     self.addRule("ID", "[a-zA-Z_][0-9a-zA-Z_]*")
  21     self.addRule("Number", r"[0-9]+")
  22     self.addRule("Char",r"'\\.'|'[^\\]'")
  23     self.addRule("SPChar", "[=<>\|]")
  24 
  25     self.addReserved(reserved_words)
  26     self.addConstant(constant_words)
  27 
  28 
  29 reserved_words = '''\
  30     and as assert
  31     begin
  32     class constraint
  33     do done downto
  34     else end exception external
  35     for fun function functor
  36     if in include inherit initializer
  37     lazy let
  38     match method module mutable
  39     new
  40     object of open or
  41     private
  42     rec
  43     sig struct
  44     then to try type
  45     val virtual
  46     when while with
  47 '''.split()
  48 
  49 constant_words = '''\
  50     true false
  51 '''.split()

MoinMoin: parser/ocaml.py (last edited 2007-10-29 19:06:23 by localhost)