librelist archives

« back to archive

Look ahead

Look ahead

From:
Philippe Rathe
Date:
2010-11-14 @ 00:57
Hello,

I saw Jison support look ahead so the following jisonlex:

	"Hello"/" World"

Get correctly map to

	Hello(?= World)

Could Jison also provide the NOT look ahead JavaScript Regex pattern  
which is fully supported

	?!

Since lex/flex does not support the NOT look ahead, is it why it is  
not supported in Jison?

I have found what lex/flex support as Regex capability here: 
http://marvin.cs.uidaho.edu/~heckendo/Handouts/regex.html

Thanks

-- Philippe



Re: [jison] Look ahead

From:
Zachary Carter
Date:
2010-11-15 @ 05:04
On Sat, Nov 13, 2010 at 7:57 PM, Philippe Rathe <prathe@gmail.com> wrote:

> Hello,
>
> I saw Jison support look ahead so the following jisonlex:
>
>        "Hello"/" World"
>
> Get correctly map to
>
>        Hello(?= World)
>
> Could Jison also provide the NOT look ahead JavaScript Regex pattern
> which is fully supported
>
>        ?!
>
> Since lex/flex does not support the NOT look ahead, is it why it is
> not supported in Jison?
>

Yes, I tried to mirror the flex API closely. They do sacrifice some advanced
features for speed, probably including "not look ahead". Including support
would mean the API would no longer be a subset of flex's API, but
realistically it's probably not a big deal. I'll consider adding some syntax
for "not" look ahead, thanks.


>
> I have found what lex/flex support as Regex capability here:
> http://marvin.cs.uidaho.edu/~heckendo/Handouts/regex.html
>
> Thanks
>
> -- Philippe
>
>
>
>
>


-- 
Zach Carter

Re: [jison] Look ahead

From:
Philippe Rathe
Date:
2010-11-15 @ 12:36
Thanks Zachary!

About performance, the "not" look ahead can sometimes avoid twisting  
regular expression/conditions and rules to achieved what  you need. So  
it is more performant.


-- Philippe




On 15-Nov-10, at 12:04 AM, Zachary Carter wrote:

>
>
> On Sat, Nov 13, 2010 at 7:57 PM, Philippe Rathe <prathe@gmail.com>  
> wrote:
> Hello,
>
> I saw Jison support look ahead so the following jisonlex:
>
>        "Hello"/" World"
>
> Get correctly map to
>
>        Hello(?= World)
>
> Could Jison also provide the NOT look ahead JavaScript Regex pattern
> which is fully supported
>
>        ?!
>
> Since lex/flex does not support the NOT look ahead, is it why it is
> not supported in Jison?
>
> Yes, I tried to mirror the flex API closely. They do sacrifice some  
> advanced features for speed, probably including "not look ahead".  
> Including support would mean the API would no longer be a subset of  
> flex's API, but realistically it's probably not a big deal. I'll  
> consider adding some syntax for "not" look ahead, thanks.
>
>
> I have found what lex/flex support as Regex capability here: 
http://marvin.cs.uidaho.edu/~heckendo/Handouts/regex.html
>
> Thanks
>
> -- Philippe
>
>
>
>
>
>
>
> -- 
> Zach Carter

Re: [jison] Look ahead

From:
Zachary Carter
Date:
2010-11-15 @ 17:17
On Mon, Nov 15, 2010 at 7:36 AM, Philippe Rathe <prathe@gmail.com> wrote:

> Thanks Zachary!
>
> About performance, the "not" look ahead can sometimes avoid twisting
> regular expression/conditions and rules to achieved what  you need. So it is
> more performant.
>
>

> -- Philippe
>

Some expressions are more expensive than others, and some engines can
achieve an order of magnitude increase in speed by limiting the supported
expressions. This has to do with the underlying algorithms the engine uses.
I'm not sure if this is why flex doesn't support "not" look aheads, but it
would be my guess. In Jison's case we are using the JavaScript engine
anyway, and your assertion is most likely true.



>
>
>
>
> On 15-Nov-10, at 12:04 AM, Zachary Carter wrote:
>
>
>
> On Sat, Nov 13, 2010 at 7:57 PM, Philippe Rathe <prathe@gmail.com> wrote:
>
>> Hello,
>>
>> I saw Jison support look ahead so the following jisonlex:
>>
>>        "Hello"/" World"
>>
>> Get correctly map to
>>
>>        Hello(?= World)
>>
>> Could Jison also provide the NOT look ahead JavaScript Regex pattern
>> which is fully supported
>>
>>        ?!
>>
>> Since lex/flex does not support the NOT look ahead, is it why it is
>> not supported in Jison?
>> < /blockquote>
>>
>> Yes, I tried to mirror the flex API closely. They do sacrifice some
>> advanced features for speed, probably including "not look ahead". Including
>> support would mean the API would no longer be a subset of flex's API, but
>> realistically it's probably not a big deal. I'll consider adding some syntax
>> for "not" look ahead, thanks.
>>
>>
>>>
>>> I have found what lex/flex support as Regex capability here:
>>> http://marvin.cs.uidaho.edu/~heckendo/Handouts/regex.html
>>>
>>> Thanks
>>>
>>> -- Philippe
>>>
>>>
>>>
>>>
>>>
>
>
> --
> Zach Carter
>
>
>


-- 
Zach Carter