Re: [code] [textadept] Parsing character literal with LPeg lexer

From: Tymur Gubayev <tymur.gubayev.att.gmail.com>
Date: Tue, 18 Feb 2014 11:48:49 +0100

The problem is the `-P("'")` pattern is combined with other patterns via
`+`, and itself can accept an empty string.

-patt Equivalent to ("" - patt)
patt1 - patt2 Matches patt1 if patt2 does not match

On 18 February 2014 11:28, suharik <suharik.att.anche.no> wrote:

> I'm trying to implement a rust lexer.
>
> Character literal are described here:
> http://static.rust-lang.org/doc/master/rust.html#character-and-string-literals
> So I wrote this:
>
> local char_body = -P("'") + P("\\") * P("'") + P("\\") * ("\\" +
> S("nrt0") + "x"*l.xdigit^2 + "u"*l.xdigit^4 + "U"*l.xdigit^8)
> local char_lit = "'" + char_body + "'"
>
> But there is a problem:
>
> Lua Error: /usr/share/textadept/lexers/lexer.lua:933: loop body may
> accept empty string.
>
> So, what's gone wrong and what "loop body may accept empty string" means?
> Textadept version: 7.1.
>
> PS: no, l.delimited_range doesn't cut it: language have things like
> "BitsNStrings<'a>".
> --
> You are subscribed to code.att.foicica.com.
> To change subscription settings, send an e-mail to code+help.att.foicica.com.
> To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
>
>

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Tue 18 Feb 2014 - 05:48:49 EST

This archive was generated by hypermail 2.2.0 : Tue 18 Feb 2014 - 06:41:00 EST