org.jscience.computing.ai.expertsystem.compiler.parser
Class Scanner

java.lang.Object
  extended by org.jscience.computing.ai.expertsystem.compiler.parser.Scanner
All Implemented Interfaces:
TokenConstants

public class Scanner
extends java.lang.Object
implements TokenConstants

Class used in the parsing of the rules file. It's the first step in the converting of the rules into Java classes.


Field Summary
 
Fields inherited from interface org.jscience.computing.ai.expertsystem.compiler.parser.TokenConstants
ACTIONS, ASTERISK, CLOSE_CURLY_BRACKET, COMMA, COMMENT, CONDITIONS, DECLARATIONS, DOT, EOF, EQUALS, ERROR, EXTENDS, IDENT, IMPLEMENTS, IMPORT, LOCALDECL, NONE_ABOVE, OPEN_CURLY_BRACKET, PACKAGE, PUBLIC, RULE, RULE_BASE, SEMICOLON, STRING, WHITE_SPACE
 
Constructor Summary
Scanner(java.lang.String ruleFileName)
          Class constructor.
 
Method Summary
 int getCurrentColumn()
          Returns the current column from the file.
 int getCurrentLine()
          Returns the current line from the file.
 Token getLastNonWhiteSpaceToken()
          Returns the last non-whitespace token.
static void main(java.lang.String[] args)
          Test method for this class.
 Token nextToken()
          Returns the next token from the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scanner

public Scanner(java.lang.String ruleFileName)
        throws java.io.IOException
Class constructor.

Parameters:
ruleFileName - the name of the rules file.
Throws:
java.io.IOException - if some IO error occurs.
Method Detail

getCurrentColumn

public int getCurrentColumn()
Returns the current column from the file.

Returns:
the current column from the file.

getCurrentLine

public int getCurrentLine()
Returns the current line from the file.

Returns:
the current line from the file.

getLastNonWhiteSpaceToken

public Token getLastNonWhiteSpaceToken()
Returns the last non-whitespace token. A whitespace token is one whose type is COMMENT or WHITE_SPACE.

Returns:
the last non-whitespace token.

main

public static void main(java.lang.String[] args)
Test method for this class.

Parameters:
args - command-line arguments. None is needed, but one can pass the rule file name for the scanning.

nextToken

public Token nextToken()
                throws java.io.IOException
Returns the next token from the file.

Returns:
the next token from the file.
Throws:
java.io.IOException - if some IO error occurs.