visionmedia-lightr 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.rdoc +16 -0
- data/Manifest +9 -3
- data/README.rdoc +3 -26
- data/Rakefile +3 -2
- data/Todo.rdoc +8 -3
- data/benchmarks/_huge.rb +1620 -0
- data/benchmarks/_large.rb +509 -0
- data/benchmarks/helper.rb +12 -0
- data/benchmarks/huge.rb +19 -0
- data/benchmarks/large.rb +20 -0
- data/examples/javascript.rb +18 -13
- data/examples/ruby.rb +12 -2
- data/ext/javascript.rl +62 -0
- data/ext/ruby.rl +83 -0
- data/lib/lightr.rb +0 -2
- data/lib/lightr/grammars.rb +0 -1
- data/lib/lightr/grammars/javascript.rb +2784 -12
- data/lib/lightr/grammars/ruby.rb +6039 -22
- data/lib/lightr/mixins/grammar.rb +9 -48
- data/lib/lightr/version.rb +1 -1
- data/lightr.gemspec +7 -7
- data/spec/grammars/javascript_spec.rb +44 -17
- data/spec/grammars/ruby_spec.rb +128 -24
- data/spec/spec_helper.rb +29 -0
- data/tasks/benchmark.rake +6 -0
- data/tasks/ext.rake +20 -0
- metadata +18 -8
- data/examples/c.rb +0 -47
- data/lib/lightr/grammars/c.rb +0 -16
- data/spec/grammars/c_spec.rb +0 -39
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visionmedia-lightr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Holowaychuk
|
@@ -9,18 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: High performance syntax highlighting.
|
17
17
|
email: tj@vision-media.ca
|
18
18
|
executables: []
|
19
19
|
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
23
|
-
-
|
23
|
+
- ext/javascript.rl
|
24
|
+
- ext/ruby.rl
|
24
25
|
- lib/lightr/grammars/javascript.rb
|
25
26
|
- lib/lightr/grammars/ruby.rb
|
26
27
|
- lib/lightr/grammars.rb
|
@@ -29,15 +30,22 @@ extra_rdoc_files:
|
|
29
30
|
- lib/lightr/version.rb
|
30
31
|
- lib/lightr.rb
|
31
32
|
- README.rdoc
|
33
|
+
- tasks/benchmark.rake
|
32
34
|
- tasks/docs.rake
|
35
|
+
- tasks/ext.rake
|
33
36
|
- tasks/gemspec.rake
|
34
37
|
- tasks/spec.rake
|
35
38
|
files:
|
36
|
-
-
|
39
|
+
- benchmarks/_huge.rb
|
40
|
+
- benchmarks/_large.rb
|
41
|
+
- benchmarks/helper.rb
|
42
|
+
- benchmarks/huge.rb
|
43
|
+
- benchmarks/large.rb
|
37
44
|
- examples/javascript.rb
|
38
45
|
- examples/ruby.rb
|
46
|
+
- ext/javascript.rl
|
47
|
+
- ext/ruby.rl
|
39
48
|
- History.rdoc
|
40
|
-
- lib/lightr/grammars/c.rb
|
41
49
|
- lib/lightr/grammars/javascript.rb
|
42
50
|
- lib/lightr/grammars/ruby.rb
|
43
51
|
- lib/lightr/grammars.rb
|
@@ -49,11 +57,12 @@ files:
|
|
49
57
|
- Manifest
|
50
58
|
- Rakefile
|
51
59
|
- README.rdoc
|
52
|
-
- spec/grammars/c_spec.rb
|
53
60
|
- spec/grammars/javascript_spec.rb
|
54
61
|
- spec/grammars/ruby_spec.rb
|
55
62
|
- spec/spec_helper.rb
|
63
|
+
- tasks/benchmark.rake
|
56
64
|
- tasks/docs.rake
|
65
|
+
- tasks/ext.rake
|
57
66
|
- tasks/gemspec.rake
|
58
67
|
- tasks/spec.rake
|
59
68
|
- Todo.rdoc
|
@@ -69,6 +78,7 @@ rdoc_options:
|
|
69
78
|
- README.rdoc
|
70
79
|
require_paths:
|
71
80
|
- lib
|
81
|
+
- ext
|
72
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
83
|
requirements:
|
74
84
|
- - ">="
|
@@ -87,6 +97,6 @@ rubyforge_project: lightr
|
|
87
97
|
rubygems_version: 1.2.0
|
88
98
|
signing_key:
|
89
99
|
specification_version: 2
|
90
|
-
summary:
|
100
|
+
summary: High performance syntax highlighting.
|
91
101
|
test_files: []
|
92
102
|
|
data/examples/c.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
|
2
|
-
require File.dirname(__FILE__) + '/../lib/lightr'
|
3
|
-
|
4
|
-
c = %|
|
5
|
-
/*
|
6
|
-
* compile.c
|
7
|
-
* ast to bytecode
|
8
|
-
*
|
9
|
-
* (c) 2008 why the lucky stiff, the freelance professor
|
10
|
-
*/
|
11
|
-
|
12
|
-
#include <stdio.h>
|
13
|
-
#include <stdlib.h>
|
14
|
-
#include <string.h>
|
15
|
-
#include <math.h>
|
16
|
-
#include "potion.h"
|
17
|
-
#include "internal.h"
|
18
|
-
#include "pn-ast.h"
|
19
|
-
#include "opcodes.h"
|
20
|
-
|
21
|
-
#define PN_ASM1(ins, _a) ({ \
|
22
|
-
(*pos)->code = (u8)ins; \
|
23
|
-
(*pos)->a = (int)_a; \
|
24
|
-
(*pos)++; \
|
25
|
-
})
|
26
|
-
|
27
|
-
const struct {
|
28
|
-
const char *name;
|
29
|
-
const u8 args;
|
30
|
-
} potion_ops[] = {
|
31
|
-
{ "noop", 0 }, { "move", 2 }, { "loadk", 2 }, { "loadpn", 2 }, { "self", 1 },
|
32
|
-
{ "newtuple", 2 }, { "settuple", 2 }, { "getlocal", 2 }, { "setlocal", 2 },
|
33
|
-
{ "getupval", 2 }, { "setupval", 2 }, { "gettable", 2 }, { "settable", 2 },
|
34
|
-
{ "getpath", 2 }, { "setpath", 2 }, { "add", 2 }, { "sub", 2 }, { "mult", 2 },
|
35
|
-
{ "div", 2 }, { "mod", 2 }, { "pow", 2 }, { "not", 1 }, { "cmp", 2 },
|
36
|
-
{ "eq", 2 }, { "neq", 2 }, { "lt", 2 }, { "lte", 2 }, { "gt", 2 }, { "gte", 2 },
|
37
|
-
{ "bitl", 2 }, { "bitr", 2 }, { "bind", 2 }, { "jump", 1 }, { "test", 2 },
|
38
|
-
{ "testjmp", 2 }, { "notjmp", 2 }, { "call", 2 }, { "tailcall", 2 },
|
39
|
-
{ "return", 1 }, { "proto", 2 },
|
40
|
-
};
|
41
|
-
|
42
|
-
PN potion_proto_call(Potion *P, PN cl, PN self, PN args) {
|
43
|
-
return potion_vm(P, self, args, 0, NULL);
|
44
|
-
}
|
45
|
-
|
|
46
|
-
|
47
|
-
puts Lightr::C.parse(c)
|
data/lib/lightr/grammars/c.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
# TODO: multi-line comments
|
3
|
-
# TODO: pre-processor directives / macros
|
4
|
-
|
5
|
-
module Lightr
|
6
|
-
class C
|
7
|
-
include Grammar
|
8
|
-
id = /\w[\w\d]*/
|
9
|
-
int = /\d+/
|
10
|
-
match :keyword, /(NULL|if|else|asm|auto|break|case|char|const|continue|default|do|double|enum|extern|float|for|goto|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)(?:\n|\z| )/
|
11
|
-
match :string, /'.*?'|".*?"/
|
12
|
-
match :comment, %r{//.*?(\n|\z)}
|
13
|
-
match :number, /-?#{int}(?:\.#{int})?/
|
14
|
-
match nil, /\n|\s|.+?/
|
15
|
-
end
|
16
|
-
end
|
data/spec/grammars/c_spec.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
|
2
|
-
describe Lightr::C do
|
3
|
-
|
4
|
-
def parse string
|
5
|
-
Lightr::C.parse(string).to_s
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "should highlight" do
|
9
|
-
|
10
|
-
it 'strings' do
|
11
|
-
parse('"test"').should include('class="string">"test"')
|
12
|
-
parse("'test'").should include(%(class="string">'test'))
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'comments' do
|
16
|
-
parse('test // comment').should include('class="comment">// comment')
|
17
|
-
end
|
18
|
-
|
19
|
-
# it "pre-processor directives/ macros" do
|
20
|
-
# parse('#define VERSION = "0.0.1"').should include('class="pre_processor">#define')
|
21
|
-
# end
|
22
|
-
|
23
|
-
%w( NULL if else asm auto break case char const continue default do double enum extern
|
24
|
-
float for goto int long register return short signed sizeof static struct
|
25
|
-
switch typedef union unsigned void volatile while ).
|
26
|
-
each do |keyword|
|
27
|
-
it "#{keyword.strip} as a keyword" do
|
28
|
-
parse("#{keyword.strip} foo").should include(%(class="keyword">#{keyword.strip} <))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should not highlight // within strings as comment' do
|
35
|
-
parse('"//test"').should include(%(class="string">"//test"))
|
36
|
-
parse("'//test'").should include(%(class="string">'//test'))
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|