Merge new upstream release 4.0.0+git20210223.6654d48.
Debian Janitor
2 years ago
0 | arch: | |
1 | - amd64 | |
2 | - ppc64le | |
0 | 3 | language: ruby |
1 | 4 | install: |
2 | 5 | - sudo apt-get install libpcre3 libpcre3-dev libmagic-dev gperf gcc ragel swig |
49 | 49 | |
50 | 50 | Ohcount does not support Windows. |
51 | 51 | |
52 | Ohcount targets Ruby 2.5.0. The ruby dev headers provided by Ubuntu/Fedora | |
53 | package managers were found to be missing a *config.h* header file. Installing | |
54 | ruby using brew/rbenv/rvm works better for compiling ohcount. | |
55 | ||
56 | 52 | Source Code |
57 | 53 | ----------- |
58 | 54 | |
63 | 59 | Building Ohcount |
64 | 60 | ---------------- |
65 | 61 | |
66 | > Last updated: 2019-01-28 | |
62 | > Last updated: 2020-02-12 | |
63 | ||
64 | Ohcount targets `Ruby 2.*`. The ruby dev headers provided by Ubuntu/Fedora | |
65 | package managers were found to be missing a `config.h` header file. If the | |
66 | default ruby and ruby-dev packages do not work, install ruby using | |
67 | brew/rbenv/asdf/rvm, which work reliably with ohcount. | |
67 | 68 | |
68 | 69 | You will need ragel 7.0 or higher, bash, gperf, libpcre3-dev, libmagic-dev, |
69 | 70 | gcc(version 7.3 or greater) and swig (>=3.0.0). |
71 | For older gcc versions one could try [this fix](https://github.com/blackducksoftware/ohcount/pull/70/commits/c7511b9810a8660a8268a958fee0e365fb9af18f). | |
72 | ||
73 | ``` | |
74 | $ git clone git://github.com/blackducksoftware/ohcount.git | |
75 | $ cd ohcount | |
76 | ``` | |
77 | ||
78 | For the ruby bindings, there is a dependency for the 'test-unit' gem: | |
79 | ``` | |
80 | $ gem install test-unit | |
81 | ``` | |
70 | 82 | |
71 | 83 | #### Ubuntu/Debian |
72 | 84 | |
89 | 101 | $ ./build |
90 | 102 | ``` |
91 | 103 | |
92 | For the ruby bindings, there is a dependency for the 'test-unit' gem: | |
104 | #### Other Unix systems | |
93 | 105 | |
94 | ``` | |
95 | $ gem install test-unit | |
96 | ``` | |
106 | * If build fails with a missing `ohcount.so` error and any `ruby/x86.../` folder has the file, copy it to `ruby/` folder. | |
97 | 107 | |
98 | 108 | Using Ohcount |
99 | 109 | ------------- |
0 | ohcount (4.0.0-2) UNRELEASED; urgency=medium | |
0 | ohcount (4.0.0+git20210223.6654d48-1) UNRELEASED; urgency=medium | |
1 | 1 | |
2 | 2 | * Bump debhelper from old 9 to 12. |
3 | 3 | * Set debhelper-compat version in Build-Depends. |
4 | 4 | * Set upstream metadata fields: Repository, Repository-Browse. |
5 | 5 | |
6 | -- Debian Janitor <janitor@jelmer.uk> Thu, 21 Nov 2019 03:29:25 +0000 | |
6 | -- Debian Janitor <janitor@jelmer.uk> Fri, 26 Mar 2021 18:27:12 -0000 | |
7 | 7 | |
8 | 8 | ohcount (4.0.0-1) unstable; urgency=medium |
9 | 9 |
50 | 50 | cu, LANG_CUDA |
51 | 51 | cxx, LANG_CPP |
52 | 52 | d, LANG_DMD |
53 | dart, LANG_DART | |
53 | 54 | dat, DISAMBIGUATE("dat") |
54 | 55 | def, DISAMBIGUATE("def") |
55 | 56 | di, LANG_DMD |
197 | 198 | sci, LANG_SCILAB |
198 | 199 | scm, LANG_SCHEME |
199 | 200 | sh, LANG_SHELL |
201 | sld, LANG_SCHEME | |
200 | 202 | sls, LANG_SCHEME |
201 | 203 | sps, LANG_SCHEME |
202 | 204 | sql, LANG_SQL |
31 | 31 | csharp, LANG_CSHARP, "C#", 0 |
32 | 32 | css, LANG_CSS, "CSS", 1 |
33 | 33 | cuda, LANG_CUDA, "CUDA", 0 |
34 | dart, LANG_DART, "Dart", 0 | |
34 | 35 | dcl, LANG_DCL, "DCL", 0 |
35 | 36 | dmd, LANG_DMD, "D", 0 |
36 | 37 | dtx, LANG_TEX_DTX, "DTX for TeX/LaTeX", 1 |
24 | 24 | #include "../parsers/css.h" |
25 | 25 | #include "../parsers/d.h" |
26 | 26 | #include "../parsers/dcl.h" |
27 | #include "../parsers/dart.h" | |
27 | 28 | #include "../parsers/dylan.h" |
28 | 29 | #include "../parsers/ebuild.h" |
29 | 30 | #include "../parsers/eiffel.h" |
134 | 135 | csharp, parse_csharp |
135 | 136 | css, parse_css |
136 | 137 | cuda, parse_cuda |
138 | dart, parse_dart | |
137 | 139 | dcl, parse_dcl |
138 | 140 | dmd, parse_d |
139 | 141 | dylan, parse_dylan |
33 | 33 | #define LANG_CSHARP "csharp" |
34 | 34 | #define LANG_CSS "css" |
35 | 35 | #define LANG_CUDA "cuda" |
36 | #define LANG_DART "dart" | |
36 | 37 | #define LANG_DCL "dcl" |
37 | 38 | #define LANG_DMD "dmd" |
38 | 39 | #define LANG_DYLAN "dylan" |
0 | /************************* Required for every parser *************************/ | |
1 | #ifndef OHCOUNT_DART_PARSER_H | |
2 | #define OHCOUNT_DART_PARSER_H | |
3 | ||
4 | #include "../parser_macros.h" | |
5 | ||
6 | // the name of the language | |
7 | const char *DART_LANG = LANG_DART; | |
8 | ||
9 | // the languages entities | |
10 | const char *dart_entities[] = { | |
11 | "space", "comment", "any" | |
12 | }; | |
13 | ||
14 | // constants associated with the entities | |
15 | enum { | |
16 | DART_SPACE = 0, DART_COMMENT, DART_ANY | |
17 | }; | |
18 | ||
19 | /*****************************************************************************/ | |
20 | ||
21 | %%{ | |
22 | machine dart; | |
23 | write data; | |
24 | include common "common.rl"; | |
25 | ||
26 | # Line counting machine | |
27 | ||
28 | action dart_ccallback { | |
29 | switch(entity) { | |
30 | case DART_SPACE: | |
31 | ls | |
32 | break; | |
33 | case DART_ANY: | |
34 | code | |
35 | break; | |
36 | case INTERNAL_NL: | |
37 | std_internal_newline(DART_LANG) | |
38 | break; | |
39 | case NEWLINE: | |
40 | std_newline(DART_LANG) | |
41 | } | |
42 | } | |
43 | ||
44 | dart_line_comment = | |
45 | '//' @comment ( | |
46 | escaped_newline %{ entity = INTERNAL_NL; } %dart_ccallback | |
47 | | | |
48 | ws | |
49 | | | |
50 | (nonnewline - ws) @comment | |
51 | )*; | |
52 | dart_block_comment = | |
53 | '/*' @comment ( | |
54 | newline %{ entity = INTERNAL_NL; } %dart_ccallback | |
55 | | | |
56 | ws | |
57 | | | |
58 | (nonnewline - ws) @comment | |
59 | )* :>> '*/'; | |
60 | dart_comment = dart_line_comment | dart_block_comment; | |
61 | ||
62 | dart_line := |* | |
63 | spaces ${ entity = DART_SPACE; } => dart_ccallback; | |
64 | dart_comment; | |
65 | newline ${ entity = NEWLINE; } => dart_ccallback; | |
66 | ^space ${ entity = DART_ANY; } => dart_ccallback; | |
67 | *|; | |
68 | ||
69 | # Entity machine | |
70 | # TODO: This is a placeholder and most entities are missing. | |
71 | ||
72 | action dart_ecallback { | |
73 | callback(DART_LANG, dart_entities[entity], cint(ts), cint(te), userdata); | |
74 | } | |
75 | ||
76 | dart_line_comment_entity = '//' (escaped_newline | nonnewline)*; | |
77 | dart_block_comment_entity = '/*' any* :>> '*/'; | |
78 | dart_comment_entity = dart_line_comment_entity | dart_block_comment_entity; | |
79 | ||
80 | dart_entity := |* | |
81 | space+ ${ entity = DART_SPACE; } => dart_ecallback; | |
82 | dart_comment_entity ${ entity = DART_COMMENT; } => dart_ecallback; | |
83 | ^space; | |
84 | *|; | |
85 | }%% | |
86 | ||
87 | /************************* Required for every parser *************************/ | |
88 | ||
89 | /* Parses a string buffer with Dart code. | |
90 | * | |
91 | * @param *buffer The string to parse. | |
92 | * @param length The length of the string to parse. | |
93 | * @param count Integer flag specifying whether or not to count lines. If yes, | |
94 | * uses the Ragel machine optimized for counting. Otherwise uses the Ragel | |
95 | * machine optimized for returning entity positions. | |
96 | * @param *callback Callback function. If count is set, callback is called for | |
97 | * every line of code, comment, or blank with 'lcode', 'lcomment', and | |
98 | * 'lblank' respectively. Otherwise callback is called for each entity found. | |
99 | */ | |
100 | void parse_dart(char *buffer, int length, int count, | |
101 | void (*callback) (const char *lang, const char *entity, int s, | |
102 | int e, void *udata), | |
103 | void *userdata | |
104 | ) { | |
105 | init | |
106 | ||
107 | %% write init; | |
108 | cs = (count) ? dart_en_dart_line : dart_en_dart_entity; | |
109 | %% write exec; | |
110 | ||
111 | // if no newline at EOF; callback contents of last line | |
112 | if (count) { process_last_line(DART_LANG) } | |
113 | } | |
114 | ||
115 | #endif | |
116 | ||
117 | /*****************************************************************************/⏎ |
0 | dart code void main() { | |
1 | dart comment // Line comment | |
2 | dart blank | |
3 | dart comment /* Block | |
4 | dart comment comment */ | |
5 | dart blank | |
6 | dart code print("Hello!"); // Code with line comment | |
7 | dart code print("World!"); /* Code with block comment */ | |
8 | dart code } |
0 | void main() { | |
1 | // Line comment | |
2 | ||
3 | /* Block | |
4 | comment */ | |
5 | ||
6 | print("Hello!"); // Code with line comment | |
7 | print("World!"); /* Code with block comment */ | |
8 | } |
220 | 220 | ASSERT_DETECT(LANG_BFPP, "foo.bfpp"); |
221 | 221 | } |
222 | 222 | |
223 | void test_detector_dart() { | |
224 | ASSERT_DETECT(LANG_DART, "foo.dart"); | |
225 | } | |
226 | ||
223 | 227 | void test_detector_emacs_mode() { |
224 | 228 | ASSERT_DETECT(LANG_C, "emacs_mode_c"); |
225 | 229 | } |
271 | 275 | test_detector_basic(); |
272 | 276 | test_detector_xml_with_custom_extension(); |
273 | 277 | test_detector_brainfuck(); |
278 | test_detector_dart(); | |
274 | 279 | test_detector_emacs_mode(); |
275 | 280 | test_detector_emacs_with_extension(); |
276 | 281 | test_detector_puppet(); |
97 | 97 | #include "parsers/test_csharp.h" |
98 | 98 | #include "parsers/test_css.h" |
99 | 99 | #include "parsers/test_d.h" |
100 | #include "parsers/test_dart.h" | |
100 | 101 | #include "parsers/test_dcl.h" |
101 | 102 | #include "parsers/test_dylan.h" |
102 | 103 | #include "parsers/test_ebuild.h" |
287 | 288 | all_cs_aspx_tests(); |
288 | 289 | all_csharp_tests(); |
289 | 290 | all_css_tests(); |
291 | all_dart_tests(); | |
290 | 292 | all_dmd_tests(); |
291 | 293 | all_dcl_tests(); |
292 | 294 | all_dylan_tests(); |
0 | ||
1 | void test_dart_comments() { | |
2 | test_parser_verify_parse( | |
3 | test_parser_sourcefile("dart", " //comment"), | |
4 | "dart", "", "//comment", 0 | |
5 | ); | |
6 | } | |
7 | ||
8 | void test_dart_empty_comments() { | |
9 | test_parser_verify_parse( | |
10 | test_parser_sourcefile("dart", " //\n"), | |
11 | "dart", "", "//\n", 0 | |
12 | ); | |
13 | } | |
14 | ||
15 | void test_dart_block_comment() { | |
16 | test_parser_verify_parse( | |
17 | test_parser_sourcefile("dart", "/*comment*/"), | |
18 | "dart", "", "/*comment*/", 0 | |
19 | ); | |
20 | } | |
21 | ||
22 | void test_dart_comment_entities() { | |
23 | test_parser_verify_entity( | |
24 | test_parser_sourcefile("dart", " //comment"), | |
25 | "comment", "//comment" | |
26 | ); | |
27 | test_parser_verify_entity( | |
28 | test_parser_sourcefile("c", " /*comment*/"), | |
29 | "comment", "/*comment*/" | |
30 | ); | |
31 | } | |
32 | ||
33 | void all_dart_tests() { | |
34 | test_dart_comments(); | |
35 | test_dart_empty_comments(); | |
36 | test_dart_block_comment(); | |
37 | test_dart_comment_entities(); | |
38 | } |