Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c1fe6da9ee8c
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 00c5f91041eb
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Jul 30, 2016

  1. Compiler: removed useless var

    Ary Borenszweig committed Jul 30, 2016
    Copy the full SHA
    5d59adf View commit details
  2. Fixed #3066: consider /= as starting a regex in some places

    Ary Borenszweig committed Jul 30, 2016
    Copy the full SHA
    00c5f91 View commit details
Showing with 12 additions and 4 deletions.
  1. +8 −1 spec/compiler/lexer/lexer_spec.cr
  2. +2 −0 spec/compiler/parser/parser_spec.cr
  3. +1 −2 src/compiler/crystal/macros/interpreter.cr
  4. +1 −1 src/compiler/crystal/syntax/lexer.cr
9 changes: 8 additions & 1 deletion spec/compiler/lexer/lexer_spec.cr
Original file line number Diff line number Diff line change
@@ -230,7 +230,7 @@ describe "Lexer" do
assert_syntax_error "'\\", "unterminated char literal"
it_lexes_operators [:"=", :"<", :"<=", :">", :">=", :"+", :"-", :"*", :"(", :")",
:"==", :"!=", :"=~", :"!", :",", :".", :"..", :"...", :"&&", :"||",
:"|", :"{", :"}", :"?", :":", :"+=", :"-=", :"*=", :"/=", :"%=", :"&=",
:"|", :"{", :"}", :"?", :":", :"+=", :"-=", :"*=", :"%=", :"&=",
:"|=", :"^=", :"**=", :"<<", :">>", :"%", :"&", :"|", :"^", :"**", :"<<=",
:">>=", :"~", :"[]", :"[]=", :"[", :"]", :"::", :"<=>", :"=>", :"||=",
:"&&=", :"===", :";", :"->", :"[]?", :"{%", :"{{", :"%}", :"@[", :"!~"]
@@ -438,6 +438,13 @@ describe "Lexer" do
token.value.should eq("\\")
end

it "lexes /=" do
lexer = Lexer.new("/=")
lexer.slash_is_regex = false
token = lexer.next_token
token.type.should eq(:"/=")
end

assert_syntax_error "'\\uFEDZ'", "expected hexadecimal character in unicode escape"
assert_syntax_error "'\\u{}'", "expected hexadecimal character in unicode escape"
assert_syntax_error "'\\u{110000}'", "invalid unicode codepoint (too large)"
2 changes: 2 additions & 0 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
@@ -808,13 +808,15 @@ describe "Parser" do
it_parses "/(fo\#{\"bar\"}\#{1}o)/", RegexLiteral.new(StringInterpolation.new(["(fo".string, "bar".string, 1.int32, "o)".string] of ASTNode))
it_parses "%r(foo(bar))", regex("foo(bar)")
it_parses "/ /", regex(" ")
it_parses "/=/", regex("=")
it_parses "/ hi /", regex(" hi ")
it_parses "self / number", Call.new("self".var, "/", "number".call)
it_parses "a == / /", Call.new("a".call, "==", regex(" "))
it_parses "/ /", regex(" ")
it_parses "/ /; / /", [regex(" "), regex(" ")] of ASTNode
it_parses "/ /\n/ /", [regex(" "), regex(" ")] of ASTNode
it_parses "a = / /", Assign.new("a".var, regex(" "))
it_parses "a = /=/", Assign.new("a".var, regex("="))
it_parses "a; if / /; / /; elsif / /; / /; end", ["a".call, If.new(regex(" "), regex(" "), If.new(regex(" "), regex(" ")))]
it_parses "a; if / /\n/ /\nelsif / /\n/ /\nend", ["a".call, If.new(regex(" "), regex(" "), If.new(regex(" "), regex(" ")))]
it_parses "a; while / /; / /; end", ["a".call, While.new(regex(" "), regex(" "))]
3 changes: 1 addition & 2 deletions src/compiler/crystal/macros/interpreter.cr
Original file line number Diff line number Diff line change
@@ -103,8 +103,7 @@ module Crystal
# are shown in the block instead of in the generated macro source
is_yield = node.exp.is_a?(Yield) && !@last.is_a?(Nop)
@str << " begin " if is_yield
emit_loc_pragma = is_yield
@last.to_s(@str, emit_loc_pragma: emit_loc_pragma)
@last.to_s(@str, emit_loc_pragma: is_yield)
@str << " end " if is_yield
end

2 changes: 1 addition & 1 deletion src/compiler/crystal/syntax/lexer.cr
Original file line number Diff line number Diff line change
@@ -269,7 +269,7 @@ module Crystal
line = @line_number
column = @column_number
char = next_char
if char == '='
if !@slash_is_regex && char == '='
next_char :"/="
elsif @slash_is_regex
@token.type = :DELIMITER_START