Class: Lrama::Lexer

Inherits:
Object
  • Object
show all
Includes:
Report::Duration
Defined in:
lib/lrama/lexer.rb,
lib/lrama/lexer/token.rb,
lib/lrama/lexer/token/type.rb

Overview

Lexer for parse.y

Defined Under Namespace

Classes: Token

Constant Summary collapse

Initial =
0
Prologue =
1
BisonDeclarations =
2
GrammarRules =
3
Epilogue =
4

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Report::Duration

enable, enabled?, #report_duration

Constructor Details

#initialize(text) ⇒ Lexer

Returns a new instance of Lexer.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/lrama/lexer.rb', line 24

def initialize(text)
  @text = text
  @state = Initial
  # Array of texts
  @prologue = []
  @bison_declarations = []
  @grammar_rules = []
  @epilogue = []

  @bison_declarations_tokens = []
  @grammar_rules_tokens = []

  @debug = false

  report_duration(:lex) do
    lex_text
    lex_bison_declarations_tokens
    lex_grammar_rules_tokens
  end
end

Instance Attribute Details

#bison_declarationsObject (readonly)

Token types



21
22
23
# File 'lib/lrama/lexer.rb', line 21

def bison_declarations
  @bison_declarations
end

#bison_declarations_tokensObject (readonly)

Token types



21
22
23
# File 'lib/lrama/lexer.rb', line 21

def bison_declarations_tokens
  @bison_declarations_tokens
end

#epilogueObject (readonly)

Token types



21
22
23
# File 'lib/lrama/lexer.rb', line 21

def epilogue
  @epilogue
end

#grammar_rulesObject (readonly)

Token types



21
22
23
# File 'lib/lrama/lexer.rb', line 21

def grammar_rules
  @grammar_rules
end

#grammar_rules_tokensObject (readonly)

Token types



21
22
23
# File 'lib/lrama/lexer.rb', line 21

def grammar_rules_tokens
  @grammar_rules_tokens
end

#prologueObject (readonly)

Token types



21
22
23
# File 'lib/lrama/lexer.rb', line 21

def prologue
  @prologue
end