simpledb.parse
Class Lexer

java.lang.Object
  extended by simpledb.parse.Lexer

public class Lexer
extends Object

The lexical analyzer.

Author:
Edward Sciore

Constructor Summary
Lexer(String s)
          Creates a new lexical analyzer for SQL statement s.
 
Method Summary
 void eatDelim(char d)
          Throws an exception if the current token is not the specified delimiter.
 String eatId()
          Throws an exception if the current token is not an identifier.
 int eatIntConstant()
          Throws an exception if the current token is not an integer.
 void eatKeyword(String w)
          Throws an exception if the current token is not the specified keyword.
 String eatStringConstant()
          Throws an exception if the current token is not a string.
 boolean matchDelim(char d)
          Returns true if the current token is the specified delimiter character.
 boolean matchId()
          Returns true if the current token is a legal identifier.
 boolean matchIntConstant()
          Returns true if the current token is an integer.
 boolean matchKeyword(String w)
          Returns true if the current token is the specified keyword.
 boolean matchStringConstant()
          Returns true if the current token is a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lexer

public Lexer(String s)
Creates a new lexical analyzer for SQL statement s.

Parameters:
s - the SQL statement
Method Detail

matchDelim

public boolean matchDelim(char d)
Returns true if the current token is the specified delimiter character.

Parameters:
d - a character denoting the delimiter
Returns:
true if the delimiter is the current token

matchIntConstant

public boolean matchIntConstant()
Returns true if the current token is an integer.

Returns:
true if the current token is an integer

matchStringConstant

public boolean matchStringConstant()
Returns true if the current token is a string.

Returns:
true if the current token is a string

matchKeyword

public boolean matchKeyword(String w)
Returns true if the current token is the specified keyword.

Parameters:
w - the keyword string
Returns:
true if that keyword is the current token

matchId

public boolean matchId()
Returns true if the current token is a legal identifier.

Returns:
true if the current token is an identifier

eatDelim

public void eatDelim(char d)
Throws an exception if the current token is not the specified delimiter. Otherwise, moves to the next token.

Parameters:
d - a character denoting the delimiter

eatIntConstant

public int eatIntConstant()
Throws an exception if the current token is not an integer. Otherwise, returns that integer and moves to the next token.

Returns:
the integer value of the current token

eatStringConstant

public String eatStringConstant()
Throws an exception if the current token is not a string. Otherwise, returns that string and moves to the next token.

Returns:
the string value of the current token

eatKeyword

public void eatKeyword(String w)
Throws an exception if the current token is not the specified keyword. Otherwise, moves to the next token.

Parameters:
w - the keyword string

eatId

public String eatId()
Throws an exception if the current token is not an identifier. Otherwise, returns the identifier string and moves to the next token.

Returns:
the string value of the current token


Copyright © 2011. All Rights Reserved.