Class: LanguageParser::CT_State

Inherits:
Object
  • Object
show all
Defined in:
lib/cgialib/lp/CTokenizer.rb

Overview

class : CT_State

The base class state object for the C-Tokenizer state machine.

Constant Summary collapse

@@specials =

Special characters that are found as delineators in C

{ ";" => 1, "," => 1, ":" => 1, "{" => 1, "}" => 1,
"(" => 1, ")" => 1, "[" => 1, "]" => 1, "%" => 1,
"+" => 1, "-" => 1, "*" => 1, "." => 1 }

Instance Method Summary collapse

Constructor Details

#initialize(newstate, addtoken) ⇒ CT_State

initialize( newstate, addtoken )

newstate - A method to be called to change state addtoken - The method to be called to add a token

Intializes the state object



28
29
30
31
32
33
# File 'lib/cgialib/lp/CTokenizer.rb', line 28

def initialize( newstate, addtoken )
  
  @newstate = newstate
  @addtoken = addtoken
  
end

Instance Method Details

#next(ch) ⇒ Object

next( ch )

ch - The character

All states should override this method. This handles a character from the stream. Returning true means that the parsing should continue to the next character. Returning false means the parser should stay on the current character.



44
45
46
47
48
# File 'lib/cgialib/lp/CTokenizer.rb', line 44

def next( ch )
  
  true
  
end