Context dependent while token get

5 views
Skip to first unread message

finik...@yandex.ru

unread,
Mar 10, 2008, 8:47:34 AM3/10/08
to GOLD Parsing System
Hi to all!
I'm using GOLD Parser to parse JavaScript files and have some problem
while define rule to select regular expression construction. In
example from GOLD Parser site a regular expression constructions
define as one of termial simbols. This definition create a porblem to
parse expression of the kind
xy=var1/2-var2/2+(var3/2-var4/2);
The parsing engine raise error. It recognize "/2-var2/" and "/2-var4/"
as regexp, but it's simple arithmetic expression.
Can you help me to describe grammar for parse this case.
For detect regexp is used next rule:
{RegExp Chars} = {Letter}+{Digit}+['^']+['$']+['*']+['+']+['?']+['{']+
['}']+['|']+['-']+['.']+[',']+['#']+['[']+[']']+['_']+['<']+['>']+['(']
+[')']
RegExp = '/' ({RegExp Chars} | '\' {Non Terminator})+ '/' ( 'g' | 'i'
| 'm' )*

Thanks,
Alexis

P.S. Sorry of my english.

Dave Dolan

unread,
Mar 10, 2008, 9:08:14 AM3/10/08
to gold-pars...@googlegroups.com
Without doing all of the math myself for this particular case, I can speak in the general sense.  When I have trouble with terminals being too greedy, I implement the same concepts in non-terminals, where I can be more specific. Perhaps it would be better to recoginze them as productions instead of terminals since there isn't a way to 'weight' which terminals one should be given precedence.
--
---------------------------------------------------------------
Dave Dolan
Certified Computer Geek-inator
http://davedolan.com/blog
dave....@gmail.com

finik...@yandex.ru

unread,
Mar 19, 2008, 12:46:32 PM3/19/08
to GOLD Parsing System

On 10 мар, 16:08, "Dave Dolan" <dave.do...@gmail.com> wrote:
> Without doing all of the math myself for this particular case, I can speak
> in the general sense. When I have trouble with terminals being too greedy,
> I implement the same concepts in non-terminals, where I can be more
> specific. Perhaps it would be better to recoginze them as productions
> instead of terminals since there isn't a way to 'weight' which terminals one
> should be given precedence.

Thank you for answer!
But regexp construction can consist of every possible characters
(exclude '/' and linefeed).
Therefore it is absorbing all other terminals and whitespace, escape
simbols, inverted commas and other simbol string chars.
On the other hand simbol string may absorb regexp terminator '/'.
It create a large porblem, for example, the parser may tangle a
terminal simbols.
I don't known which terminal(!) simbols must be defined in this case.
Please help me to describe gramatic for this particular case.

Thanks,
Alexis

P.S. ooo... sorry, of my english....

Manfred_Nowak

unread,
Mar 20, 2008, 8:23:13 AM3/20/08
to GOLD Parsing System


On Mar 19, 5:46 pm, finik-2...@yandex.ru wrote:
> But regexp construction can consist of every possible characters
> (exclude '/' and linefeed).
> On the other hand simbol string may absorb regexp terminator '/'.

Your problems may be caused by a language that is not deterministic
context free.

Please recall:
If this is the case nobody will be able to create a parser with GOLD
or any other LALR(1) system.
Because only you have the specification of the intended language only
you can prove wether it is not deterministic context free.
Not being able to prove this fact, does not mean that the intended
language is deterministic context free.
And beeing able to prove the intended language as being deterministic
context free is equivalent to provide a grammar for that language,
where GOLD does not report any conflicts.

In total this means, that you ask the community to do the main part of
your work.

-manfred
Reply all
Reply to author
Forward
0 new messages