def parse_quote
beg, nnd, short_hand, c = nil, nil, false, nil
if src.scan(/[a-z0-9]{1,2}/i) then
rb_compile_error "unknown type of %string" if src.matched_size == 2
c, beg, short_hand = src.matched, src.getch, false
else
c, beg, short_hand = 'Q', src.getch, true
end
if src.eos? or c == RubyLexer::EOF or beg == RubyLexer::EOF then
rb_compile_error "unterminated quoted string meets end of file"
end
nnd = { "(" => ")", "[" => "]", "{" => "}", "<" => ">" }[beg]
nnd, beg = beg, "\0" if nnd.nil?
token_type, self.yacc_value = nil, "%#{c}#{beg}"
token_type, string_type = case c
when 'Q' then
ch = short_hand ? nnd : c + beg
self.yacc_value = "%#{ch}"
[:tSTRING_BEG, STR_DQUOTE]
when 'q' then
[:tSTRING_BEG, STR_SQUOTE]
when 'W' then
src.scan(/\s*/)
[:tWORDS_BEG, STR_DQUOTE | STR_FUNC_QWORDS]
when 'w' then
src.scan(/\s*/)
[:tQWORDS_BEG, STR_SQUOTE | STR_FUNC_QWORDS]
when 'x' then
[:tXSTRING_BEG, STR_XQUOTE]
when 'r' then
[:tREGEXP_BEG, STR_REGEXP]
when 's' then
self.lex_state = :expr_fname
[:tSYMBEG, STR_SSYM]
end
rb_compile_error "Bad %string type. Expected [Qq\Wwxrs], found '#{c}'." if
token_type.nil?
self.lex_strterm = [:strterm, string_type, nnd, beg]
return token_type
end