Re: [textadept] Re: Lexer

From: mitchell <c....at.caladbolg.net>
Date: Wed, 15 Jun 2011 22:34:52 -0400 (EDT)

Hi Anton,

On Wed, 15 Jun 2011, anton wrote:

> Thanks. But sorry, I still don't get it. Why is this not working?
>
> local preprocessor = token(l.PREPROCESSOR,#P('a') * P('ta'))

This says "match the character a, but do not consume any input, then match
the sequence 'ta'". Naturally this is impossible since text cannot match
'a' and 'ta' at the same position. The solution is to have

> local preprocessor = token(l.PREPROCESSOR,#P('a') * P('ata'))

Does this help?

mitchell

>
> _rules = {
> { 'whitespace', ws },
> { 'preprocessor', preprocessor},
> { 'any_char', l.any_char },
> }
>
> on "new sata drives"
>
> The reference says
> "The order of the rules is important because of the nature of LPeg.
> LPeg tries to apply the first rule to the current position in the text
> it is matching. If there is a match, it colors that section
> appropriately and moves on. If there is not a match, it tries the next
> rule, and so on."
> What does
> "The '#' operator matches without consuming anything"
> mean?
> If I have "new sata drives" string
> LPeg will apply any_char 3 times, whitespace, any char, then
> presumably it should apply
> preprocessor to lex ta, and then at what position will it go on?
>
> anton
> P.S.: Sorry...
>
>
>
>
>
> On 15 Jun., 15:16, Robert <ro....at.web.de> wrote:
>> On Wed, Jun 15, 2011 at 2:58 PM, mitchell <c....at.caladbolg.net> wrote:
>>> Hi Anton,
>>
>>> On Wed, 15 Jun 2011, anton wrote:
>>
>>>> The main problem is that if I do something wrong in a module, TA
>>>> (well, Lua) gives a meaningful
>>>> error message. If I do something wrong in a lexer TA simply crashes.
>>
>>> Error messages will be printed to STDOUT or STDERR in Linux.
>>
>> Also, to quote from the manual:
>> "Poorly written lexers have the ability to crash Scintilla, so unsaved
>> data might be lost. However, these crashes have only been observed in
>> early lexer development, when syntax errors or pattern errors are
>> present. Once the lexer actually starts styling text (either correctly
>> or incorrectly; it does not matter), no crashes have occurred."
>>
>> Robert
>
> --
> You received this message because you are subscribed to the Google Groups "textadept" group.
> To post to this group, send email to textadept.at.googlegroups.com.
> To unsubscribe from this group, send email to textadept+unsubscribe.at.googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/textadept?hl=en.
>
>

mitchell
Received on Wed 15 Jun 2011 - 22:34:52 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:11:02 EST