grammatica-users
[Top][All Lists]
Advanced

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

Re: [Grammatica-users] basic question


From: Leo Ferres
Subject: Re: [Grammatica-users] basic question
Date: Fri, 18 Feb 2005 14:46:22 -0500 (EST)

Dear Per and J.;

That was a prompt reply, thank you.

As per your suggestions, I've both added a "newline" at the end of 
myString:

myString=myString + "\n";

and I've corrected the (horrible) programming mistake that Per pointed 
out. The method now reads:

        private static Node parseFOL(String input) throws 
ParserCreationException,
                        ParserLogException {

                Parser parser=null;
                parser = new MyGramParser(new StringReader(input));
                Node node=parser.parse();
                System.out.println(node);
                return node;
                
        }

It still doesn't work, though now, no error is printed. Here's a sample 
run:

The latter one is expected, the first one is not. Here it is:

FOL:> BLUE(boy)
[Fri Feb 18 14:33:32 EST 2005]: Parsing BLUE(boy)...
Sentence(2001)
FOL:> BLUE(
[Fri Feb 18 14:33:40 EST 2005]: Parsing BLUE(...
unexpected end of file, on line 2 column: 1
FOL:> 

And here's my toy grammar: 

%header%

GRAMMARTYPE = "LL"

DESCRIPTION = "A grammar for a simple FOL language."

AUTHOR      = "Leo Ferres, <lferres at ccs dot carleton dot ca>"
VERSION     = "1.0"
DATE        = "February 2005"

LICENSE     = "Permission is granted to copy this document verbatim in 

any
               medium, provided that this copyright notice is left 

intact."

COPYRIGHT   = "Copyright (c) 2005 Leo Ferres for the HOTLab. All rights 

reserved."

%tokens%

EXISTENTIAL                  = "\exists"
CONJUNCTION                  = "\wedge"
UNIVERSAL                    = "\forall"
DISJUNCTION                  = "\vee"
NEGATION                     = "\neg"
TRUTH                        = "True"
FALSITY                      = "False"
LEFT_PAREN                   = "("
RIGHT_PAREN                  = ")"
ARGUMENT_SEPARATOR           = ","
NUMBER                       = <<[0-9]+>>
PREDICATE                    = <<[A-Z]+>>
WORD                         = <<[a-z]+>>
WHITESPACE                   = <<[ \t\n\r]+>> %ignore%

%productions%

Sentence = simpleSentence | ComplexSentence ;

simpleSentence = PREDICATE "(" WORD ")" ;

ComplexSentence = NEGATION Sentence ;

I appreciate your help.

Best regards,

Leo




reply via email to

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