Skip to content

Commit 0e7b5b1

Browse files
committed
Brings library up to date with Crystal 1.7.1
This commit modifies the specs based on ziprandom#7 as well as updates usage of type expressions to be compatible with newer Crystal
1 parent bdffe14 commit 0e7b5b1

File tree

10 files changed

+16
-16
lines changed

10 files changed

+16
-16
lines changed

spec/cltk/parser_msgpack_spec.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ArrayCalc2 < CLTK::Parser
99
clause("PLS e e") { |args| args = args.as(Array); args[1].as(Int32) + args[2].as(Int32) }
1010
clause("SUB e e") { |args| args = args.as(Array); args[1].as(Int32) - args[2].as(Int32) }
1111
clause("MUL e e") { |args| args = args.as(Array); args[1].as(Int32) * args[2].as(Int32) }
12-
clause("DIV e e") { |args| args = args.as(Array); args[1].as(Int32) / args[2].as(Int32) }
12+
clause("DIV e e") { |args| args = args.as(Array); args[1].as(Int32) // args[2].as(Int32) }
1313
nil
1414
end
1515

spec/cltk/parser_spec.cr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class AmbiguousParser < CLTK::Parser
7777
clause("e PLS e") { |e0, op, e1 | e0.as(Int32) + e1.as(Int32) }
7878
clause("e SUB e") { |e0, op, e1 | e0.as(Int32) - e1.as(Int32) }
7979
clause("e MUL e") { |e0, op, e1 | e0.as(Int32) * e1.as(Int32) }
80-
clause("e DIV e") { |e0, op, e1 | e0.as(Int32) / e1.as(Int32) }
80+
clause("e DIV e") { |e0, op, e1 | e0.as(Int32) // e1.as(Int32) }
8181
end
8282

8383
finalize
@@ -92,7 +92,7 @@ class ArrayCalc < CLTK::Parser
9292
clause("PLS e e") { |args| args = args.as(Array); args[1].as(Int32) + args[2].as(Int32) }
9393
clause("SUB e e") { |args| args = args.as(Array); args[1].as(Int32) - args[2].as(Int32) }
9494
clause("MUL e e") { |args| args = args.as(Array); args[1].as(Int32) * args[2].as(Int32) }
95-
clause("DIV e e") { |args| args = args.as(Array); args[1].as(Int32) / args[2].as(Int32) }
95+
clause("DIV e e") { |args| args = args.as(Array); args[1].as(Int32) // args[2].as(Int32) }
9696
nil
9797
end
9898

@@ -218,7 +218,7 @@ class ErrorCalc < CLTK::Parser
218218
clause("e PLS e") { |e0, op, e1| e0.as(Int32) + e1.as(Int32) }
219219
clause("e SUB e") { |e0, op, e1| e0.as(Int32) - e1.as(Int32) }
220220
clause("e MUL e") { |e0, op, e1| e0.as(Int32) * e1.as(Int32) }
221-
clause("e DIV e") { |e0, op, e1| e0.as(Int32) / e1.as(Int32) }
221+
clause("e DIV e") { |e0, op, e1| e0.as(Int32) // e1.as(Int32) }
222222
clause("e PLS ERROR e") do |e0, op, ts, e1|
223223
error(ts);
224224
e0.as(Int32) + e1.as(Int32)
@@ -275,7 +275,7 @@ class RotatingCalc < CLTK::Parser
275275
->(a : Int32, b : Int32) { a + b }, # +
276276
->(a : Int32, b : Int32) { a - b }, # -
277277
->(a : Int32, b : Int32) { a * b }, # *
278-
->(a : Int32, b : Int32) { a / b } # /
278+
->(a : Int32, b : Int32) { a // b } # /
279279
]
280280

281281
def get_op(orig_op)

src/cltk/cfg.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ module CLTK
264264
production
265265
end
266266

267-
def callback(&callback: Symbol, Symbol, Production, Array(Int32)-> Nil)
267+
def callback(&callback : Symbol, Symbol, Production, Array(Int32)-> Nil)
268268
@callback = callback
269269
nil
270270
end

src/cltk/lexer/environment.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ module CLTK
1717
# @param [Symbol] start_state Lexer's start state.
1818
# @param [Match] match Match object for matching text.
1919

20-
@state: Array(Symbol)
21-
@match: Regex::MatchData?
20+
@state : Array(Symbol)
21+
@match : Regex::MatchData?
2222

2323
def match
2424
@match.as(Regex::MatchData)

src/cltk/parser.cr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ module CLTK
244244
end
245245

246246
# Shorthands for defining productions and clauses
247-
def self.c(expression, precedence = nil, arg_type = @@default_arg_type, &action: Array(Type), Environment -> _)
247+
def self.c(expression, precedence = nil, arg_type = @@default_arg_type, &action : Array(Type), Environment -> _)
248248
self.clause(expression, precedence, arg_type, &action)
249249
end
250250

251-
def self.p(symbol, expression = nil, precedence = nil, arg_type = @@default_arg_type, &action: Array(Type), Environment -> _)
251+
def self.p(symbol, expression = nil, precedence = nil, arg_type = @@default_arg_type, &action : Array(Type), Environment -> _)
252252
self.production(symbol, expression, precedence, arg_type, &action)
253253
end
254254

@@ -824,7 +824,7 @@ module CLTK
824824
# @param [Proc] proc Code to execute when the block is seen
825825
#
826826
# @return [void]
827-
def self.token_hook(sym, &proc: Proc(Environment, Nil))
827+
def self.token_hook(sym, &proc : Proc(Environment, Nil))
828828
if CFG.is_terminal?(sym)
829829
@@token_hooks[sym.to_s] << proc
830830
else

src/cltk/parser/state.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module CLTK
1313
getter :actions
1414

1515
@id = -1
16-
@actions: Hash(String, Array(CLTK::Parser::Action))
16+
@actions : Hash(String, Array(CLTK::Parser::Action))
1717

1818
def initialize(@id : Int32, @actions : Hash(String, Array(CLTK::Parser::Action)), @items : Array(CFG::Item)); end
1919
# Instantiate a new State object.

src/cltk/parsers/infix_calc.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module CLTK
3030
clause("e PLS e") { |e0, op, e1| e0.as(Int32) + e1.as(Int32) }
3131
clause("e SUB e") { |e0, op, e1| e0.as(Int32) - e1.as(Int32) }
3232
clause("e MUL e") { |e0, op, e1| e0.as(Int32) * e1.as(Int32) }
33-
clause("e DIV e") { |e0, op, e1| e0.as(Int32) / e1.as(Int32) }
33+
clause("e DIV e") { |e0, op, e1| e0.as(Int32) // e1.as(Int32) }
3434
end
3535

3636
finalize

src/cltk/parsers/postfix_calc.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module CLTK
2222
clause("e e PLS") { |e0, e1, op| e0.as(Int32) + e1.as(Int32) }
2323
clause("e e SUB") { |e0, e1, op| e0.as(Int32) - e1.as(Int32) }
2424
clause("e e MUL") { |e0, e1, op| e0.as(Int32) * e1.as(Int32) }
25-
clause("e e DIV") { |e0, e1, op| e0.as(Int32) / e1.as(Int32) }
25+
clause("e e DIV") { |e0, e1, op| e0.as(Int32) // e1.as(Int32) }
2626
nil
2727
end
2828

src/cltk/parsers/prefix_calc.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module CLTK
2222
clause("PLS e e") { |op, e0, e1| e0.as(Int32) + e1.as(Int32) }
2323
clause("SUB e e") { |op, e0, e1| e0.as(Int32) - e1.as(Int32) }
2424
clause("MUL e e") { |op, e0, e1| e0.as(Int32) * e1.as(Int32) }
25-
clause("DIV e e") { |op, e0, e1| e0.as(Int32) / e1.as(Int32) }
25+
clause("DIV e e") { |op, e0, e1| e0.as(Int32) // e1.as(Int32) }
2626
nil
2727
end
2828

src/cltk/scanner.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ module CLTK
274274
# wrap the given block to be yielded in an Environment
275275
private macro block_to_proc(&block)
276276
{%unless block.is_a? Nop %}
277-
ProcType.new do |{{block.args.first}}, env|
277+
ProcType.new do |{{block.args.first || "_".id }}, env|
278278
env.yield_with_self do
279279
{{block.body}}
280280
end

0 commit comments

Comments
 (0)