[antlr-interest] ANTLR 3.0.1 - Disambiguating semantic predicate question

Karthik Abram karthik.abram at neovera.com
Mon May 12 14:51:51 PDT 2008


The attached file has a grammer that attempts to parse a simple language to
"log" your hours into a timesheet application. 

 

Statements are of the form:

 

log <time> <project> <date>

 

where <time> is required a decimal with an optional plus sign

<project> is of the form "in <subproject-name>" and is optional

<date> is of the form "for <date-spec>" where date-spec can be things like
"monday" "last monday" "yesterday" "today" etc.

 

The attached grammar works, except when I input the command:

log +30.25 for last monday

 

it fails the predicate for "in" and fails the predicate for "for" and
erroneously says that the project name is "for" instead of creating an AST
with project set to default project. However, the sentence "log +30.25 for
monday" parses just fine.

 

I don't understand why it fails the predicate for "in" but continues to go
down that path. When I set k=5 in the logCommand expression it works for
this case but fails other cases. Any help pointing me towards what I'm doing
wrong is highly appreciated!

 

Karthik Abram

Neovera, Inc.

703-462-1823

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080512/348bcb0d/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AcademicHourGlass.g
Type: application/octet-stream
Size: 2747 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080512/348bcb0d/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5131 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080512/348bcb0d/attachment.bin 


More information about the antlr-interest mailing list