riml 0.3.0 → 0.3.1
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/lib/lexer.rb +6 -6
- data/version.rb +2 -2
- metadata +2 -2
data/lib/lexer.rb
CHANGED
@@ -5,7 +5,7 @@ module Riml
|
|
5
5
|
class Lexer
|
6
6
|
include Riml::Constants
|
7
7
|
|
8
|
-
SINGLE_LINE_COMMENT_REGEX = /\A\
|
8
|
+
SINGLE_LINE_COMMENT_REGEX = /\A[ \t\f]*"(.*)$/
|
9
9
|
OPERATOR_REGEX = /\A#{Regexp.union(['||', '&&', '===', '+=', '-=', '.='] + COMPARISON_OPERATORS)}/
|
10
10
|
INTERPOLATION_REGEX = /"([^"]*?)(\#\{([^"]*?)\})([^"]*?)"/m
|
11
11
|
ANCHORED_INTERPOLATION_REGEX = /\A#{INTERPOLATION_REGEX}/m
|
@@ -63,14 +63,14 @@ module Riml
|
|
63
63
|
def tokenize_chunk(chunk)
|
64
64
|
@chunk = chunk
|
65
65
|
# deal with line continuations
|
66
|
-
if cont = chunk[/\A\n
|
66
|
+
if cont = chunk[/\A\r?\n*[ \t\f]*\\/m]
|
67
67
|
@i += cont.size
|
68
68
|
@lineno += cont.each_line.to_a.size - 1
|
69
69
|
return
|
70
70
|
end
|
71
71
|
|
72
72
|
# all lines that start with ':' pass right through unmodified
|
73
|
-
if (prev_token.nil? || prev_token[0] == :NEWLINE) && (ex_literal = chunk[/\A\
|
73
|
+
if (prev_token.nil? || prev_token[0] == :NEWLINE) && (ex_literal = chunk[/\A[ \t\f]*:(.*)?$/])
|
74
74
|
@i += ex_literal.size
|
75
75
|
@token_buf << [:EX_LITERAL, $1]
|
76
76
|
return
|
@@ -171,7 +171,7 @@ module Riml
|
|
171
171
|
elsif (single_line_comment = chunk[SINGLE_LINE_COMMENT_REGEX]) && (prev_token.nil? || prev_token[0] == :NEWLINE)
|
172
172
|
@i += single_line_comment.size + 1 # consume next newline character
|
173
173
|
@lineno += single_line_comment.each_line.to_a.size
|
174
|
-
elsif inline_comment = chunk[/\A\
|
174
|
+
elsif inline_comment = chunk[/\A[ \t\f]*"[^"]*?$/]
|
175
175
|
@i += inline_comment.size # inline comment, don't consume newline character
|
176
176
|
@lineno += inline_comment.each_line.to_a.size - 1
|
177
177
|
elsif string_double = chunk[/\A"(.*?)(?<!\\)"/, 1]
|
@@ -180,7 +180,7 @@ module Riml
|
|
180
180
|
elsif string_single = chunk[/\A'(([^']|'')*)'/, 1]
|
181
181
|
@token_buf << [:STRING_S, string_single]
|
182
182
|
@i += string_single.size + 2
|
183
|
-
elsif newlines = chunk[/\A(\n+)/, 1]
|
183
|
+
elsif newlines = chunk[/\A([\r\n]+)/, 1]
|
184
184
|
# push only 1 newline
|
185
185
|
@token_buf << [:NEWLINE, "\n"] unless prev_token && prev_token[0] == :NEWLINE
|
186
186
|
|
@@ -216,7 +216,7 @@ module Riml
|
|
216
216
|
elsif regexp = chunk[%r{\A/.*?[^\\]/}]
|
217
217
|
@token_buf << [:REGEXP, regexp]
|
218
218
|
@i += regexp.size
|
219
|
-
elsif whitespaces = chunk[/\A\
|
219
|
+
elsif whitespaces = chunk[/\A[ \t\f]+/]
|
220
220
|
@i += whitespaces.size
|
221
221
|
# operators and tokens of single chars, one of: ( ) , . [ ] ! + - = < > /
|
222
222
|
else
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: racc
|