regular expression problem in tokens

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

regular expression problem in tokens

Wieger Wesselink
Hi,

when I put the regular expression '\d+(-\d+)+' in a token I would
expect that the string '1-23' is accepted. However, I get the following
error:

Parse tree from 1.pdn:
Error: in 1.pdn: line 1:
      unexpected character '1'

1-23
^

I have verified on http://www.fileformat.info/tool/regex.htm that
the string '1-23' matches with '\d+(-\d+)+'.

Is this a bug in Grammatica, or am I doing something wrong? For the
full grammar see below.

Best regards,

Wieger

-----------------------------

%header%

GRAMMARTYPE = "LL"

%tokens%

NUMBERS    = <<\d+(-\d+)+>>
WHITESPACE = <<[ \t\n\r]+>> %ignore%

%productions%

Start = NUMBERS ;



--
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 9 at http://www.opera.com

Powered by Outblaze


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

Re: regular expression problem in tokens

Wieger Wesselink
I found a workaround for the problem. Using '[\d]+(-[\d]+)+'
instead of '\d+(-\d+)+' makes it accept '1-23'.

BTW, it took me about an hour to port a grammar to Grammatica
and start using it, whereas I struggled for half a day with
ANTLR and still didn't get it right because of the many peculiar
undocumented behaviors in their implementation. So thanks and
keep up the good work!

Wieger

> ----- Original Message -----
> From: "Wieger Wesselink" <[hidden email]>
> To: [hidden email]
> Subject: [Grammatica-users] regular expression problem in tokens
> Date: Sun, 17 May 2009 23:54:12 +0100
>
>
> Hi,
>
> when I put the regular expression '\d+(-\d+)+' in a token I would
> expect that the string '1-23' is accepted. However, I get the following
> error:
>
> Parse tree from 1.pdn:
> Error: in 1.pdn: line 1:
>        unexpected character '1'
>
> 1-23
> ^
>
> I have verified on http://www.fileformat.info/tool/regex.htm that
> the string '1-23' matches with '\d+(-\d+)+'.
>
> Is this a bug in Grammatica, or am I doing something wrong? For the
> full grammar see below.
>
> Best regards,
>
> Wieger
>
> -----------------------------
>
> %header%
>
> GRAMMARTYPE = "LL"
>
> %tokens%
>
> NUMBERS    = <<\d+(-\d+)+>>
> WHITESPACE = <<[ \t\n\r]+>> %ignore%
>
> %productions%
>
> Start = NUMBERS ;
>
>
>
> --
> _______________________________________________
> Surf the Web in a faster, safer and easier way:
> Download Opera 9 at http://www.opera.com
>
> Powered by Outblaze
>
>
> _______________________________________________
> Grammatica-users mailing list
> [hidden email]
> http://lists.nongnu.org/mailman/listinfo/grammatica-users

>


--
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 9 at http://www.opera.com

Powered by Outblaze


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

Re: regular expression problem in tokens

Per Cederberg
In reply to this post by Wieger Wesselink
Yes, this looks like a bug in the new DFA regexp implementation. I'll
look into it in a few days when I have more time.

Thanks for reporting it!

/Per

On Mon, May 18, 2009 at 00:54, Wieger Wesselink <[hidden email]> wrote:

> Hi,
>
> when I put the regular expression '\d+(-\d+)+' in a token I would
> expect that the string '1-23' is accepted. However, I get the following
> error:
>
> Parse tree from 1.pdn:
> Error: in 1.pdn: line 1:
>      unexpected character '1'
>
> 1-23
> ^
>
> I have verified on http://www.fileformat.info/tool/regex.htm that
> the string '1-23' matches with '\d+(-\d+)+'.
>
> Is this a bug in Grammatica, or am I doing something wrong? For the
> full grammar see below.
>
> Best regards,
>
> Wieger
>
> -----------------------------
>
> %header%
>
> GRAMMARTYPE = "LL"
>
> %tokens%
>
> NUMBERS    = <<\d+(-\d+)+>>
> WHITESPACE = <<[ \t\n\r]+>> %ignore%
>
> %productions%
>
> Start = NUMBERS ;
>
>
>
> --
> _______________________________________________
> Surf the Web in a faster, safer and easier way:
> Download Opera 9 at http://www.opera.com
>
> Powered by Outblaze
>
>
> _______________________________________________
> 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