lib/hotcell/lexerr.rl in hotcell-0.2.0 vs lib/hotcell/lexerr.rl in hotcell-0.3.0

- old
+ new

@@ -1,7 +1,7 @@ %%{ - machine puffer_lexer; + machine hotcell_lexer; variable data @data; variable te @te; variable ts @ts; variable p @p; @@ -11,10 +11,37 @@ emit_operator; fgoto expression; end } + action Interpolate { + @braces_count = 0; + emit_interpolation + fcall interpolation; + } + + action OpenBrace { + emit_operator + @braces_count += 1 + } + + action CloseBrace { + if @braces_count < 1 + emit_interpolation + fret; + else + emit_operator + @braces_count -= 1 + end + } + + action ParseDstring { + @dstring_start = @ts + emit_dstring_open + fcall dstring; + } + include "lexer.rl"; }%% Hotcell::Lexer.class_eval do def current_position @@ -45,9 +72,14 @@ %% write exec; #% raise_unexpected_symbol unless @ts.nil? + + if cs == hotcell_lexer_en_dstring + @ts = @dstring_start + raise_unterminated_string + end @token_array end end