com.svincent.moksa
Class MiniPrologParser

java.lang.Object
  |
  +--com.svincent.moksa.WamObject
        |
        +--com.svincent.moksa.PrologParser
              |
              +--com.svincent.moksa.MiniPrologParser

public class MiniPrologParser
extends PrologParser

Parses a subset of the Prolog language, that I call 'Mini-Prolog'.

Moksa includes two Prolog parsers: this one, written entirely in Java, and another, which supports the entire ISO Prolog grammar, written in Prolog.

This parser may one day be extended to parse all of Prolog.

Mini-Prolog is defined as follows:

Clause
Head :- Body.
Clause
:- Body.
Clause
Head.
Head
Term
Body
TermList
TermList
Term (, Term)*
Term
(Term)
Term
Const
Term
Variable
Term
CompoundTerm
Term
List
CompoundTerm
ID (TermList)
List
[TermList(|Term)?]
Const
ID | INTEGER | REAL | STRING
Variable
VARIABLE

A pleasant property of this language is that it is LA(1). It never has to peek ahead more than one token.


Constructor Summary
MiniPrologParser(Io _io)
           
 
Method Summary
 PrologTerm parseClause(Io.PrologInput in)
          Parse a Prolog clause.
 PrologTerm parseTerm(Io.PrologInput in)
          Parse a Prolog term.
 
Methods inherited from class com.svincent.moksa.PrologParser
parseClause, parseFile, parseTerm
 
Methods inherited from class com.svincent.moksa.WamObject
tag, tag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MiniPrologParser

public MiniPrologParser(Io _io)
Method Detail

parseClause

public PrologTerm parseClause(Io.PrologInput in)
                       throws java.io.IOException,
                              PrologParseException
Description copied from class: PrologParser

Parse a Prolog clause. This ends at the next end ('.') character, and typically contains something of the form "Term :- Term, Term."

Returns null on EOF.

Overrides:
parseClause in class PrologParser

parseTerm

public PrologTerm parseTerm(Io.PrologInput in)
                     throws java.io.IOException,
                            PrologParseException
Description copied from class: PrologParser

Parse a Prolog term. This is the primitive term stuff we're all familiar with: atoms, integers, compound terms, floats, etc.

Returns null on EOF.

Overrides:
parseTerm in class PrologParser



This is documentation for Moksa Prolog, which can be found at http://www.svincent.com/moksa/

Copyright © 1999 Shawn P. Vincent.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.