visionmedia-lightr 0.0.3 → 0.0.4

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 CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ === 0.0.4 / 2009-03-07
3
+
4
+ * Added ruby string alternative (:"foo bar")
5
+ * Added class / inst vars for Ruby grammar
6
+ * Fixed; Ids should start with alpha / _
7
+
2
8
  === 0.0.3 / 2009-03-07
3
9
 
4
10
  * Added C example
data/examples/ruby.rb CHANGED
@@ -12,6 +12,10 @@ module Foo
12
12
  @n = n
13
13
  end
14
14
 
15
+ def foo
16
+ return :"this works too"
17
+ end
18
+
15
19
  end
16
20
  end
17
21
  }
@@ -4,7 +4,8 @@
4
4
 
5
5
  module Lightr
6
6
  class C
7
- include Grammar
7
+ include Grammar
8
+ id = /\w[\w\d]*/
8
9
  int = /\d+/
9
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| )/
10
11
  match :string, /'.*?'|".*?"/
@@ -2,7 +2,7 @@
2
2
  module Lightr
3
3
  class JavaScript
4
4
  include Grammar
5
- id = /[\w\d]*/
5
+ id = /\w[\w\d]*/
6
6
  int = /\d+/
7
7
  match :keyword, /(if|else|throw|break|case|catch|continue|default|delete|do|double|true|false|final|finally|float|for|function|int|instanceof|in|long|new|null|return|short|switch|throw|try|typeof|var|void|while|with)(?:\n|\z| )/
8
8
  match :string, /'.*?'|".*?"/
@@ -10,15 +10,17 @@
10
10
  module Lightr
11
11
  class Ruby
12
12
  include Grammar
13
- id = /[\w\d]*/
13
+ id = /\w[\w\d]*/
14
14
  int = /\d[\d_]*/
15
+ string = /'.*?'|".*?"/
15
16
  match :keyword, /(if|else|elsif|unless|retry|super|then|true|while|until|class|module|defined|end|in|alias|BEGIN|END|begin|break|def|do|nil|not|or|and|redo|rescue|return|yield)(?:\n|\z| )/
16
- match :string, /'.*?'|".*?"/
17
+ match :symbol, /:(#{id}|#{string})/
18
+ match :string, string
17
19
  match :regexp, %r{/.*?/[\w]*}
18
20
  match :self, /self/
19
21
  match :comment, /#.*?(\n|\z)/
20
22
  match :constant, /[A-Z]#{id}/
21
- match :symbol, /:#{id}/
23
+ match :variable, /@@?#{id}/
22
24
  match :number, /-?#{int}(?:\.#{int})?/
23
25
  match nil, /\n|\s|.+?/
24
26
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Lightr
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
data/lightr.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{lightr}
5
- s.version = "0.0.3"
5
+ s.version = "0.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Holowaychuk"]
@@ -9,6 +9,7 @@ describe Lightr::Ruby do
9
9
 
10
10
  it 'symbols' do
11
11
  parse('a :symbol').should include('class="symbol">:symbol')
12
+ parse(':"foo bar" test').should include('class="symbol">:&quot;foo bar&quot;<')
12
13
  end
13
14
 
14
15
  it 'strings' do
@@ -33,6 +34,14 @@ describe Lightr::Ruby do
33
34
  parse('/test/sex test').should include('class="regexp">/test/sex<')
34
35
  end
35
36
 
37
+ it "instance variables" do
38
+ parse('@foo_1').should include('class="variable">@foo_1<')
39
+ end
40
+
41
+ it "class variables" do
42
+ parse('@@__bar').should include('class="variable">@@__bar<')
43
+ end
44
+
36
45
  %w( 11 1_000 1.1 1.100_00 ).each do |number|
37
46
  it "#{number} as number" do
38
47
  parse(number).should include('class="number"')
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk