grammatica-users
[Top][All Lists]
Advanced

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

Re: [Grammatica-users] basic question


From: Per Cederberg
Subject: Re: [Grammatica-users] basic question
Date: Sat, 19 Feb 2005 09:56:02 +0100

The results you are getting are actually both correct and
expected... :-)

Thing is, the toString() method in the Node subclasses does
not print the whole parse tree, just the node itself. So in
the first case you most certainly have a complete parse tree
like this:

  Sentence
    simpleSentence
      PREDICATE "BLUE"
      (
      WORD "boy"
      )

You can use the printTo() method if you wish to print the
whole parse tree. Like this:

   node.printTo(System.out);

Hope this helps!

/Per

On fri, 2005-02-18 at 14:46 -0500, Leo Ferres wrote:
> 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]