Skip to content

Commit 42bb2a4

Browse files
committed
Run bundle exec rake stree:write
1 parent ab6e669 commit 42bb2a4

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

lib/syntax_tree/cli.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def run(item)
193193
class Expr < Action
194194
def run(item)
195195
program = item.handler.parse(item.source)
196-
if Program === program and expressions = program.statements.body and expressions.size == 1
196+
if Program === program and expressions = program.statements.body and
197+
expressions.size == 1
197198
puts expressions.first.construct_keys
198199
else
199200
warn("The input to `stree expr` must be a single expression.")

lib/syntax_tree/pattern.rb

+12-5
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,16 @@ def compile_node(root)
114114
clazz = Object.const_get(root.value)
115115

116116
->(node) { node.is_a?(clazz) }
117-
elsif ConstPathRef === root and VarRef === root.parent and Const === root.parent.value and root.parent.value.value == "SyntaxTree"
117+
elsif ConstPathRef === root and VarRef === root.parent and
118+
Const === root.parent.value and
119+
root.parent.value.value == "SyntaxTree"
118120
compile_node(root.constant)
119121
elsif DynaSymbol === root and root.parts.empty?
120122
symbol = :""
121123

122124
->(node) { node == symbol }
123-
elsif DynaSymbol === root and parts = root.parts and parts.size == 1 and TStringContent === parts[0]
125+
elsif DynaSymbol === root and parts = root.parts and parts.size == 1 and
126+
TStringContent === parts[0]
124127
symbol = parts[0].value.to_sym
125128

126129
->(node) { node == symbol }
@@ -129,7 +132,9 @@ def compile_node(root)
129132

130133
preprocessed =
131134
root.keywords.to_h do |keyword, value|
132-
raise CompilationError, PP.pp(root, +"").chomp unless keyword.is_a?(Label)
135+
unless keyword.is_a?(Label)
136+
raise CompilationError, PP.pp(root, +"").chomp
137+
end
133138
[keyword.value.chomp(":").to_sym, compile_node(value)]
134139
end
135140

@@ -146,13 +151,15 @@ def compile_node(root)
146151
else
147152
compiled_keywords
148153
end
149-
elsif RegexpLiteral === root and parts = root.parts and parts.size == 1 and TStringContent === parts[0]
154+
elsif RegexpLiteral === root and parts = root.parts and
155+
parts.size == 1 and TStringContent === parts[0]
150156
regexp = /#{parts[0].value}/
151157

152158
->(attribute) { regexp.match?(attribute) }
153159
elsif StringLiteral === root and root.parts.empty?
154160
->(attribute) { attribute == "" }
155-
elsif StringLiteral === root and parts = root.parts and parts.size == 1 and TStringContent === parts[0]
161+
elsif StringLiteral === root and parts = root.parts and
162+
parts.size == 1 and TStringContent === parts[0]
156163
value = parts[0].value
157164
->(attribute) { attribute == value }
158165
elsif SymbolLiteral === root

0 commit comments

Comments
 (0)