Separating out tokens - need help

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Separating out tokens - need help

paskal sanil
Hi,

I have the following grammar (Included only the relevant grammar):

Production
-------------
               PExpression      = PTerm [PRest];
               PRest  = "AND" PExpression | "OR" PExpression ;
               PTerm =  FORM_PARAM | ....

Formula
---------
                FORM_PARAM       = "Z" ":" "(" ZBooleanExpr ")"

           ZBooleanExpr     = IDENTIFIER Comparator YIELD_IDENTIFIER
             Comparator = LIKE | EQ | NE;
             YIELD_IDENTIFIER = "'" LIKE_TEXT "'" |  "'" ANY_TEXT "'" | ....

Regular Expression
-----------------------------

LIKE_TEXT   = <<[a-zA-Z0-9][a-zA-Z0-9%_/]*[a-zA-Z0-9]+>>

Problem is that when i give a String like

Str1  ->   Z:(Id1 LIKE '%abc%' ) OR Z:(Id1 LIKE '%xyz%')

It gives the error:

Expected: " ' "
Found : "') OR Z:(Id1 LIKE '"


However the above works fine if use a <Space> in the following String:
Str2 -> Z:(Id1 LIKE '%abc%'<space> ) OR Z:(Id1 LIKE '%xyz%')
or don't use '%'
Str3 -> Z:(Id1 LIKE 'abc' ) OR Z:(Id1 LIKE 'xyz')

How can i make the ")" to be recognized as a separate token?

Please suggest some work around in the "grammar" to make Str1 work.

Thanks in advance,
paskal sanil


_______________________________________________
Grammatica-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/grammatica-users
Reply | Threaded
Open this post in threaded view
|

Re: Separating out tokens - need help

Leszek Doniec
Hi,
 
I am not sure if I am right, but I think that when you use string with % at first position it will not be parsed as LIKE_TEXT, since LIKE_TEXT starts with a letter or digit. So send us the definition of ANY_TEXT or change LIKE_TEXT definition.
 
Cheers,
Leszek

 
2008/2/7, paskal sanil <[hidden email]>:
Hi,

I have the following grammar (Included only the relevant grammar):

Production
-------------
              PExpression      = PTerm [PRest];
              PRest  = "AND" PExpression | "OR" PExpression ;
              PTerm =  FORM_PARAM | ....

Formula
---------
               FORM_PARAM       = "Z" ":" "(" ZBooleanExpr ")"

          ZBooleanExpr     = IDENTIFIER Comparator YIELD_IDENTIFIER
            Comparator = LIKE | EQ | NE;
            YIELD_IDENTIFIER = "'" LIKE_TEXT "'" |  "'" ANY_TEXT "'" | ....

Regular Expression
-----------------------------

LIKE_TEXT   = <<[a-zA-Z0-9][a-zA-Z0-9%_/]*[a-zA-Z0-9]+>>

Problem is that when i give a String like

Str1  ->   Z:(Id1 LIKE '%abc%' ) OR Z:(Id1 LIKE '%xyz%')

It gives the error:

Expected: " ' "
Found : "') OR Z:(Id1 LIKE '"


However the above works fine if use a <Space> in the following String:
Str2 -> Z:(Id1 LIKE '%abc%'<space> ) OR Z:(Id1 LIKE '%xyz%')
or don't use '%'
Str3 -> Z:(Id1 LIKE 'abc' ) OR Z:(Id1 LIKE 'xyz')

How can i make the ")" to be recognized as a separate token?

Please suggest some work around in the "grammar" to make Str1 work.

Thanks in advance,
paskal sanil


_______________________________________________
Grammatica-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/grammatica-users


_______________________________________________
Grammatica-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/grammatica-users
Reply | Threaded
Open this post in threaded view
|

Re: Separating out tokens - need help

paskal sanil
Thanks . Got ur point.

Just changed the regular expression to

LIKE_TEXT   = <<'[%]*[a-zA-Z0-9][a-zA-Z0-9_/]*[a-zA-Z0-9][%]*'>>

Its working.

On 2/7/08, Leszek Doniec <[hidden email]> wrote:

> Hi,
>
> I am not sure if I am right, but I think that when you use string with % at
> first position it will not be parsed as LIKE_TEXT, since LIKE_TEXT starts
> with a letter or digit. So send us the definition of ANY_TEXT or change
> LIKE_TEXT definition.
>
> Cheers,
> Leszek
>
>
> 2008/2/7, paskal sanil <[hidden email]>:
> >
> > Hi,
> >
> > I have the following grammar (Included only the relevant grammar):
> >
> > Production
> > -------------
> >               PExpression      = PTerm [PRest];
> >               PRest  = "AND" PExpression | "OR" PExpression ;
> >               PTerm =  FORM_PARAM | ....
> >
> > Formula
> > ---------
> >                FORM_PARAM       = "Z" ":" "(" ZBooleanExpr ")"
> >
> >           ZBooleanExpr     = IDENTIFIER Comparator YIELD_IDENTIFIER
> >             Comparator = LIKE | EQ | NE;
> >             YIELD_IDENTIFIER = "'" LIKE_TEXT "'" |  "'" ANY_TEXT "'" |
> > ....
> >
> > Regular Expression
> > -----------------------------
> >
> > LIKE_TEXT   = <<[a-zA-Z0-9][a-zA-Z0-9%_/]*[a-zA-Z0-9]+>>
> >
> > Problem is that when i give a String like
> >
> > Str1  ->   Z:(Id1 LIKE '%abc%' ) OR Z:(Id1 LIKE '%xyz%')
> >
> > It gives the error:
> >
> > Expected: " ' "
> > Found : "') OR Z:(Id1 LIKE '"
> >
> >
> > However the above works fine if use a <Space> in the following String:
> > Str2 -> Z:(Id1 LIKE '%abc%'<space> ) OR Z:(Id1 LIKE '%xyz%')
> > or don't use '%'
> > Str3 -> Z:(Id1 LIKE 'abc' ) OR Z:(Id1 LIKE 'xyz')
> >
> > How can i make the ")" to be recognized as a separate token?
> >
> > Please suggest some work around in the "grammar" to make Str1 work.
> >
> > Thanks in advance,
> > paskal sanil
> >
> >
> > _______________________________________________
> > Grammatica-users mailing list
> > [hidden email]
> > http://lists.nongnu.org/mailman/listinfo/grammatica-users
> >
>


_______________________________________________
Grammatica-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/grammatica-users