Class: Puppet::Pops::Parser::PNParser

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/pops/parser/pn_parser.rb

Constant Summary collapse

LIT_TRUE =
'true'.freeze
LIT_FALSE =
'false'.freeze
LIT_NIL =
'nil'.freeze
TOKEN_END =
0
TOKEN_BOOL =
1
TOKEN_NIL =
2
TOKEN_INT =
3
TOKEN_FLOAT =
4
TOKEN_IDENTIFIER =
5
TOKEN_WS =
0x20
TOKEN_STRING =
0x22
TOKEN_KEY =
0x3a
TOKEN_LP =
0x28
TOKEN_RP =
0x29
TOKEN_LB =
0x5b
TOKEN_RB =
0x5d
TOKEN_LC =
0x7b
TOKEN_RC =
0x7d
TYPE_END =
0
TYPE_WS =
1
TYPE_DELIM =
2
TYPE_KEY_START =
3
TYPE_STRING_START =
4
TYPE_IDENTIFIER =
5
TYPE_MINUS =
6
TYPE_DIGIT =
7
TYPE_ALPHA =
8

Instance Method Summary collapse

Constructor Details

#initializePNParser

Returns a new instance of PNParser.



35
36
37
# File 'lib/puppet/pops/parser/pn_parser.rb', line 35

def initialize
  @char_types = self.class.char_types
end

Instance Method Details

#parse(text, locator = nil, offset = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/puppet/pops/parser/pn_parser.rb', line 39

def parse(text, locator = nil, offset = nil)
  @locator = locator
  @offset = offset
  @text = text
  @codepoints = text.codepoints.to_a.freeze
  @pos = 0
  @token = TOKEN_END
  @token_value = nil
  next_token
  parse_next
end