Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fdccc85

Browse files
committedSep 6, 2014
[snapshot]
1 parent 284d3fd commit fdccc85

File tree

5 files changed

+1917
-1847
lines changed

5 files changed

+1917
-1847
lines changed
 

‎lib/opal/nodes/arglist.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'opal/nodes/base'
2+
require 'opal/nodes/kwargs'
23

34
module Opal
45
module Nodes

‎lib/opal/nodes/kwargs.rb

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require 'opal/nodes/base'
2+
3+
module Opal
4+
module Nodes
5+
# FIXME: needs rewrite
6+
class KWArgsNode < Base
7+
handle :kwargs
8+
9+
def compile
10+
raise inspect
11+
end
12+
end
13+
end
14+
end

‎lib/opal/parser.rb

+19
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ class Parser < Racc::Parser
1111
def parse(source, file = '(string)')
1212
@file = file
1313
@scopes = []
14+
15+
push_scope
16+
@lexer = Lexer.new(source, file)
17+
@lexer.parser = self
18+
token = @lexer.next_token
19+
p token
20+
p token while (token = @lexer.next_token)[0] != false
21+
pop_scope
22+
1423
@lexer = Lexer.new(source, file)
24+
1525
@lexer.parser = self
1626

1727
self.parse_to_sexp
@@ -304,6 +314,15 @@ def new_paren(open, expr, close)
304314
end
305315
end
306316

317+
def new_kwargs(label, value)
318+
res = s(:kwargs)
319+
scope.add_local label
320+
res << s1(:identifier, value(label), source(label))
321+
res << value if value
322+
p res
323+
res
324+
end
325+
307326
def new_args(norm, opt, rest, block)
308327
res = s(:args)
309328

‎lib/opal/parser/grammar.rb

+1,875-1,847
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/opal/parser/grammar.y

+8
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,14 @@ xstring_contents: none
14901490
{
14911491
result = new_args(nil, nil, nil, val[0])
14921492
}
1493+
| tLABEL
1494+
{
1495+
result = new_kwargs(val[0], nil)
1496+
}
1497+
| tLABEL arg_value
1498+
{
1499+
result = new_kwargs(val[0], val[1])
1500+
}
14931501
| # none
14941502
{
14951503
result = new_args(nil, nil, nil, nil)

0 commit comments

Comments
 (0)
Please sign in to comment.