Ticket #210: 0001-Add-minimal-OCaml-support.patch

File 0001-Add-minimal-OCaml-support.patch, 5.2 kB (added by Samuel Bronson, 1 year ago)

oops, I'd left one line with (too many) spaces instead of tabs... fixed.

  • a/ext/ohcount_native/generator.rb

    old new  
    5151      metafont = LineCommentMonoglot.new("metafont", "%"); 
    5252      metapost = LineCommentMonoglot.new("metapost", "%"); 
    5353      objective_c = CMonoglot.new("objective_c", '//',             [e('/*'), e('*/')], true,  false) 
     54      ocaml = CMonoglot.new("ocaml",             nil,              [e('(*'), e('*)')], true,  false) 
    5455      pascal = CMonoglot.new("pascal",           '//',             ['{','}'],          true,  true, {:no_escape_dquote => true, :no_escape_squote => true}) 
    5556      perl = CMonoglot.new("perl",               '#',              ['^=\\\\w+', '^=cut[ \t]*\\\\n'],  true,  true) 
    5657      phplanguage = CMonoglot.new("php",         ['//', '#'],             [e('/*'), e('*/')], true,  true, {:polyglot_name => 'phplanguage'}) 
     
    119120        metafont, 
    120121        metapost, 
    121122        objective_c, 
     123        ocaml, 
    122124        pascal , 
    123125        perl , 
    124126        pike , 
  • a/lib/ohcount/detector.rb

    old new  
    164164    '.lisp' => "lisp", 
    165165    '.m'    => :matlab_or_objective_c, 
    166166    '.mf'   => 'metafont', 
     167    '.ml' => 'ocaml', 
     168    '.ml4'  => 'ocaml', 
     169    '.mli'  => 'ocaml', 
    167170    '.mk'   => 'make', 
    168171    '.mm'   => "objective_c", 
    169172    '.mp'   => 'metapost_with_tex', 
  • a/lib/ohcount/sloc_info.rb

    old new  
    7272      'metapost'      => {:nice_name => 'MetaPost'         , :category => 1}, 
    7373      'mxml'          => {:nice_name => 'Flex'             , :category => 1}, 
    7474      'objective_c'   => {:nice_name => 'Objective C'      , :category => 0}, 
     75      'ocaml'         => {:nice_name => 'Objective Caml'   , :category => 0}, 
    7576      'pascal'        => {:nice_name => 'Pascal'           , :category => 0}, 
    7677      'perl'          => {:nice_name => 'Perl'             , :category => 0}, 
    7778      'php'           => {:nice_name => 'PHP'              , :category => 0}, 
  • /dev/null

    old new  
  • /dev/null

    old new  
     1let rec fib n = 
     2match n with 
     3| 0 -> 1 
     4| 1 -> 1 
     5| _ -> fib (n-2) + fib (n-1) 
     6;; 
  • /dev/null

    old new  
  • /dev/null

    old new  
     1(* really stupid way to calculate a number in the fibonacci sequence *) 
     2 
     3let rec fib n = 
     4  match n with 
     5    | 0 -> 1 
     6    | 1 -> 1 
     7    | _ -> fib (n-2) + fib (n-1) 
     8;; 
  • /dev/null

    old new  
     1# This has been shamelessly copied from java_test.rb because my Ruby is not so 
     2# good and I don't really know what people expect from a Ohcount language test 
     3#  -- Reinier Lamers 2008-01-19 
     4# Ditto from haskell_test.rb 
     5#  -- Samuel Bronson 2008-06-14 
     6require File.dirname(__FILE__) + '/../test_helper' 
     7 
     8class Ohcount::OcamlTest < Ohcount::Test 
     9  def test_comments 
     10    lb = [Ohcount::LanguageBreakdown.new("ocaml", "", "(* comment *)", 0)] 
     11    assert_equal lb, Ohcount::parse("(* comment *)", "ocaml") 
     12  end 
     13 
     14  def test_comprehensive 
     15    verify_parse("ocaml1.ml") 
     16  end 
     17end