Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## alice.tuprolog
Class Parser

    java.lang.Object
      alice.tuprolog.Parser

All Implemented Interfaces:
  java.io.Serializable

public class Parser
extends java.lang.Object
implements java.io.Serializable

This class defines a parser of prolog terms and sentences.

BNF part 2: Parser term ::= exprA(1200) exprA(n) ::= exprB(n) { op(yfx,n) exprA(n-1) | op(yf,n) }* exprB(n) ::= exprC(n-1) { op(xfx,n) exprA(n-1) | op(xfy,n) exprA(n) | op(xf,n) }* // exprC is called parseLeftSide in the code exprC(n) ::= '-' integer | '-' float | op( fx,n ) exprA(n-1) | op( fy,n ) exprA(n) | exprA(n) exprA(0) ::= integer | float | atom | variable | atom'(' exprA(1200) { ',' exprA(1200) }* ')' | '[' [ exprA(1200) { ',' exprA(1200) }* [ '|' exprA(1200) ] ] ']' | '(' { exprA(1200) }* ')' '{' { exprA(1200) }* '}' op(type,n) ::= atom | { symbol }+

See Also:
  Serialized Form

Constructor Summary
`Parser(java.io.InputStream theoryText)` creating a parser with default operator interpretation
`Parser(alice.tuprolog.OperatorManager op, java.io.InputStream theoryText)` creating a Parser specifing how to handle operators and what text to parse
`Parser(alice.tuprolog.OperatorManager op, java.lang.String theoryText)` creating a Parser specifing how to handle operators and what text to parse
`Parser(java.lang.String theoryText)` creating a parser with default operator interpretation

Method Summary
`int` | `getCurrentLine()`
`static boolean` | `isAtom(java.lang.String s)`
`java.util.Iterator` | `iterator()`
`Term` | `nextTerm(boolean endNeeded)` Parses next term from the stream built on string.
`static Term` | `parseSingleTerm(java.lang.String st)` Static service to get a term from its string representation
`static Term` | `parseSingleTerm(java.lang.String st, alice.tuprolog.OperatorManager op)` Static service to get a term from its string representation, providing a specific operator manager

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Parser

    public Parser(alice.tuprolog.OperatorManager op,
                  java.io.InputStream theoryText)

  creating a Parser specifing how to handle operators and what text to parse

### Parser

    public Parser(alice.tuprolog.OperatorManager op,
                  java.lang.String theoryText)

  creating a Parser specifing how to handle operators and what text to parse

### Parser

    public Parser(java.lang.String theoryText)

  creating a parser with default operator interpretation

### Parser

    public Parser(java.io.InputStream theoryText)

  creating a parser with default operator interpretation

Method Detail

### iterator

    public java.util.Iterator iterator()

### nextTerm

    public Term nextTerm(boolean endNeeded)
                  throws InvalidTermException

  Parses next term from the stream built on string.

  Parameters:
    `endNeeded` - `true` if it is required to parse the end token (a period), `false` otherwise.
  Throws:
    `InvalidTermException` - if a syntax error is found.

### parseSingleTerm

    public static Term parseSingleTerm(java.lang.String st)
                                throws InvalidTermException

  Static service to get a term from its string representation

  Throws:
    `InvalidTermException`

### parseSingleTerm

    public static Term parseSingleTerm(java.lang.String st,
                                       alice.tuprolog.OperatorManager op)
                                throws InvalidTermException

  Static service to get a term from its string representation, providing a specific operator manager

  Throws:
    `InvalidTermException`

### getCurrentLine

    public int getCurrentLine()

### isAtom

    public static boolean isAtom(java.lang.String s)

  Returns:
    true if the String could be a prolog atom

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD