From feaf28d4231e4d1d69b7399870aa27410c4bfa37 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 19 May 2014 20:26:07 +0200 Subject: [PATCH] Remove dedicated string machine in the XML lexer. This removes the need for another fcall/fret combination. --- ext/ragel/base_lexer.rl | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/ext/ragel/base_lexer.rl b/ext/ragel/base_lexer.rl index d10a452..b9b661d 100644 --- a/ext/ragel/base_lexer.rl +++ b/ext/ragel/base_lexer.rl @@ -47,23 +47,14 @@ dquote = '"'; squote = "'"; - # Machine for processing double quoted strings. - string_dquote := |* - ^dquote+ => { - callback("on_string", data, encoding, ts, te); - }; + string_dquote = (dquote ^dquote+ dquote); + string_squote = (squote ^squote+ squote); - dquote => { fret; }; - *|; + string = string_dquote | string_squote; - # Machine for processing single quoted strings. - string_squote := |* - ^squote+ => { - callback("on_string", data, encoding, ts, te); - }; - - squote => { fret; }; - *|; + action emit_string { + callback("on_string", data, encoding, ts + 1, te - 1); + } # DOCTYPES # @@ -96,8 +87,7 @@ }; # Lex the public/system IDs as regular strings. - dquote => { fcall string_dquote; }; - squote => { fcall string_squote; }; + string => emit_string; # Whitespace inside doctypes is ignored since there's no point in # including it. @@ -137,8 +127,7 @@ callback("on_attribute", data, encoding, ts, te); }; - dquote => { fcall string_dquote; }; - squote => { fcall string_squote; }; + string => emit_string; any; *|; @@ -192,8 +181,7 @@ }; # Attribute values. - dquote => { fcall string_dquote; }; - squote => { fcall string_squote; }; + string => emit_string; # The closing character of the open tag. ('>' | '/') => {