grammatica-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Grammatica-users] Grammar with single-quoted stings


From: Per Cederberg
Subject: Re: [Grammatica-users] Grammar with single-quoted stings
Date: Wed, 23 Mar 2011 18:52:58 +0100

Your regex for whitespace seems to include an accidental extra char at the end.

Cheers,

/Per

On Wednesday, March 23, 2011, Schilha, Matthias
<address@hidden> wrote:
> Hi,
>
> i want to write a grammar to accept strings like this: a = 'b'
>
> To do that, I write this grammar:
>
> %header%
>
> GRAMMARTYPE = "LL"
>
> %tokens%
>
> EQ                                                       = "="
>
> S_QUOTE                                          = "'"
>
> NUMBER                       = <<[0-9]+>>
> IDENTIFIER                   = <<'[A-Za-z§][A-Za-z0-9_§]*>>
> WHITESPACE                   = <<[ \t\n\r]+'>> %ignore%
>
>
> %productions%
>
>
> Expression = IDENTIFIER AtomComparisonTail;
>
> AtomComparisonTail = Comparison Atom
>                 | Comparison "'" Atom "'";
>
> Comparison = "=";
>
> Atom = NUMBER
>      | IDENTIFIER;
>
>
> But it doesn't work. I get the message: unexpected character ''', on line: 1 
> column: 3
>
> In this way I changed my grammar to
>
> %header%
>
> GRAMMARTYPE = "LL"
>
> %tokens%
>
> EQ                                                       = "="
>
> S_QUOTE                                          = "'"
>
> QUOTED_STRING                = <<('[^']*')>>
> NUMBER                       = <<[0-9]+>>
> IDENTIFIER                   = <<'[A-Za-z§][A-Za-z0-9_§]*>>
> WHITESPACE                   = <<[ \t\n\r]+'>> %ignore%
>
>
> %productions%
>
>
> Expression = IDENTIFIER AtomComparisonTail;
>
> AtomComparisonTail = Comparison Atom
>                 | Comparison QUOTED_STRING Atom QUOTED_STRING;
>
> Comparison = "=";
>
> Atom = NUMBER
>      | IDENTIFIER;
>
> But it is still not working.
>
> Have someone another idea to solve this problem.
>
> Thank you very much.
> Matthias
>
> _______________________________________________
> Grammatica-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/grammatica-users
>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]