grammar
Class ProductionChecker

java.lang.Object
  extended by grammar.ProductionChecker

public class ProductionChecker
extends java.lang.Object

Production checker

Author:
XZW

Field Summary
static java.lang.String delimiter
          Delimiter between left hand side and right hand side.
 
Constructor Summary
ProductionChecker()
          Creates an instance of production checker
 
Method Summary
static boolean isProduction(java.lang.String production)
          Checks whether a given production is invalid.
static boolean isProductionLHS(java.lang.String lhs)
          Checks whether the left hand side of a given production is invalid.
static boolean isTerminal(java.lang.String token)
          Returns true if a given token is a terminal.
static boolean isTerminalProduction(Production production)
          Returns true if a given production is a terminal production, whose RHS has no variables.
static boolean isVariable(java.lang.String token)
          Returns true if a given token is a variable.
static boolean isVariableProduction(Production production)
          Returns true if a given production is a variable production, whose RHS has at least one variable.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delimiter

public static java.lang.String delimiter
Delimiter between left hand side and right hand side.

Constructor Detail

ProductionChecker

public ProductionChecker()
Creates an instance of production checker

Method Detail

isVariable

public static boolean isVariable(java.lang.String token)
Returns true if a given token is a variable. A variable is writed as "".

Parameters:
token - the given token
Returns:
true if a given token is a variable.

isTerminal

public static boolean isTerminal(java.lang.String token)
Returns true if a given token is a terminal. A terminal is writed as "token".

Parameters:
token - the given token.
Returns:
true if a given token is a terminal.

isVariableProduction

public static boolean isVariableProduction(Production production)
Returns true if a given production is a variable production, whose RHS has at least one variable.

Returns:
true if a given production is a variable production.

isTerminalProduction

public static boolean isTerminalProduction(Production production)
Returns true if a given production is a terminal production, whose RHS has no variables.

Returns:
true if a given production is a terminal production.

isProduction

public static boolean isProduction(java.lang.String production)
Checks whether a given production is invalid. The left hand side of a production should have at least one variable.

Parameters:
production - the given production
Returns:
true if the production is valid

isProductionLHS

public static boolean isProductionLHS(java.lang.String lhs)
Checks whether the left hand side of a given production is invalid. The left hand side of a production should have at least one variable.

Parameters:
lhs - the left hand side of a given production
Returns:
true if the left hand side is valid.