From 77b40d2e817af84c0666b4ea2eb54fcf93066368 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Tue, 11 Mar 2014 21:55:36 +0100 Subject: [PATCH] Use a separate machine for closing tags. This makes it easier to advance column numbers for whitespace as well as captuing and emitting tokens for the closing tag. --- lib/oga/lexer.rl | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/oga/lexer.rl b/lib/oga/lexer.rl index a74ab94..1f4675d 100644 --- a/lib/oga/lexer.rl +++ b/lib/oga/lexer.rl @@ -269,6 +269,24 @@ module Oga }; *|; + element_closing_tag := |* + whitespace => { advance_column }; + + element_name => { + emit_text_buffer + add_token(:T_ELEM_CLOSE, nil) + + # Advance the column for the ' => { fret; }; + *|; + element := |* whitespace => { advance_column }; @@ -289,15 +307,8 @@ module Oga '=' (dquote @string_dquote | squote @string_squote); # Non self-closing elements. - ' { + fcall element_closing_tag; fret; };