Possible lexing error?

24 views
Skip to first unread message

Dave Thomas

unread,
May 14, 2013, 12:30:29 PM5/14/13
to elixir-l...@googlegroups.com
iex(13)> %W{the c#{'a'}t sat on the mat}
** (SyntaxError) iex:13: unexpected token: }


Dave

Alexei Sholik

unread,
May 14, 2013, 12:49:17 PM5/14/13
to elixir-lang-core
iex(1)> %W/the c#{'a'}t sat on the mat/
["the","c\#{'a'}t","sat","on","the","mat"]

iex(2)> %w(the c#{'a'}t sat on the mat)
["the","cat","sat","on","the","mat"]

You can use arbitrary brackets as sigil delimiters.


--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Best regards
Alexei Sholik

Yurii Rashkovskii

unread,
May 14, 2013, 12:55:10 PM5/14/13
to elixir-l...@googlegroups.com

I think José was going to fix this (extra bracket openings within a sigil). José?

José Valim

unread,
May 14, 2013, 12:56:21 PM5/14/13
to elixir-l...@googlegroups.com
I have tried once and failed miserably.

I can give it another try but it is harder than it looks like. :)

Alexei Sholik

unread,
May 14, 2013, 1:00:35 PM5/14/13
to elixir-lang-core
The first clause deals with """ and ''' syntax (hence [$%,S,H,H,H|T] as the first arg).

The second clause deals with all other delimiters. It only requires the delimiter to be not(?is_identifier(H)), not(?is_terminator(H)) (https://github.com/elixir-lang/elixir/blob/master/lib/elixir/include/elixir.hrl#L67). So, apart from paired delimiters ( [], (), {}, <>) you can also use things like /, |, ", ^, %, etc.
Reply all
Reply to author
Forward
0 new messages