From 886738ddcf0024cfc76914ae13b69c83346b06cb Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 15 Mar 2008 19:04:32 +0100 Subject: [PATCH] support CWEB (literate programming for C) --- ext/ohcount_native/generator.rb | 15 +++++++++++++++ lib/ohcount/detector.rb | 1 + lib/ohcount/sloc_info.rb | 1 + 3 files changed, 17 insertions(+) diff --git a/ext/ohcount_native/generator.rb b/ext/ohcount_native/generator.rb index 3760afd..99c2ee2 100644 --- a/ext/ohcount_native/generator.rb +++ b/ext/ohcount_native/generator.rb @@ -33,6 +33,20 @@ module Ohcount dcl = DclMonoglot.new("dcl") dylan = CMonoglot.new("dylan", '//', nil, true, false) documentation = Monoglot.new("documentation", [State.new("documentation", :text, :comment)], []) + c_web = Biglot.new("c_web", documentation, c, [ + ["documentation", :c_inner, :comment], + ], [ + ["@c(?=\\\\s)", :documentation_text, :c_code, :from, false, 'code_block'], + # This doesn't catch it the proper way if there are newlines, so use the next one + # ["@<.+?@>\\\\s*=", :documentation_text, :c_code, :from, false, 'code_ref'], + ["@>\\\\s*=", :documentation_text, :c_code, :from, false, 'code_ref'], + ["@d(?=\\\\s)", :documentation_text, :c_code, :from, false, 'code_def'], + ["@f(?=\\\\s)", :documentation_text, :c_code, :from, false, 'code_fmt'], + ["@[@'{}+/!;]", :c_code, :c_code, :to, true, 'quoted_stuff'], + ["@[.:^t<(]", :c_code, :documentation_c_inner, :to, false, 'inline'], + ["@>;?", :documentation_c_inner, :return, :from, false, 'inline'], + ["@\\\\*?(?=\\\\s)", :c_code, :return, :to, false, 'section'] + ]); erlang = CMonoglot.new("erlang", '%%', nil, true, true) java = CMonoglot.new("java", '//', [e('/*'), e('*/')], true, false) javascript = CMonoglot.new("javascript", '//', [e('/*'), e('*/')], true, true) @@ -148,6 +162,7 @@ module Ohcount php, rhtml, jsp, + c_web, knuth_web, clearsilver_template, tex, diff --git a/lib/ohcount/detector.rb b/lib/ohcount/detector.rb index cee8399..afe0968 100644 --- a/lib/ohcount/detector.rb +++ b/lib/ohcount/detector.rb @@ -188,6 +188,7 @@ class Ohcount::Detector '.vb' => "visualbasic", '.vba' => "visualbasic", '.vbs' => "visualbasic", + '.w' => "c_web", '.web' => "knuth_web", '.xml' => "xml", '.xsd' => "xmlschema", diff --git a/lib/ohcount/sloc_info.rb b/lib/ohcount/sloc_info.rb index 0d62b8a..f77fe81 100644 --- a/lib/ohcount/sloc_info.rb +++ b/lib/ohcount/sloc_info.rb @@ -46,6 +46,7 @@ class Ohcount::SlocInfo 'boo' => {:nice_name => 'Boo' , :category => 0}, 'c' => {:nice_name => 'C' , :category => 0}, 'cpp' => {:nice_name => 'C++' , :category => 0}, + 'c_web' => {:nice_name => 'CWEB' , :category => 0}, 'clearsilver' => {:nice_name => 'ClearSilver' , :category => 0}, 'csharp' => {:nice_name => 'C#' , :category => 0}, 'css' => {:nice_name => 'CSS' , :category => 1}, -- 2.32.0.93.g670b81a890