Class | PuppetLint::Lexer |
In: |
lib/puppet-lint/lexer.rb
lib/puppet-lint/lexer/token.rb |
Parent: | Object |
Internal: The puppet-lint lexer. Converts your manifest into its tokenised form.
KEYWORDS | = | { 'class' => true, 'case' => true, 'default' => true, 'define' => true, 'import' => true, 'if' => true, 'else' => true, 'elsif' => true, 'inherits' => true, 'node' => true, 'and' => true, 'or' => true, 'undef' => true, 'true' => true, 'false' => true, 'in' => true, 'unless' => true, } | Internal: A Hash whose keys are Strings representing reserved keywords in the Puppet DSL. | |
REGEX_PREV_TOKENS | = | { :NODE => true, :LBRACE => true, :RBRACE => true, :MATCH => true, :NOMATCH => true, :COMMA => true, } | Internal: A Hash whose keys are Symbols representing token types which a regular expression can follow. | |
KNOWN_TOKENS | = | [ [:CLASSREF, /\A(((::){0,1}[A-Z][-\w]*)+)/], [:NUMBER, /\A\b((?:0[xX][0-9A-Fa-f]+|0?\d+(?:\.\d+)?(?:[eE]-?\d+)?))\b/], [:NAME, /\A(((::)?[a-z0-9][-\w]*)(::[a-z0-9][-\w]*)*)/], [:LBRACK, /\A(\[)/], [:RBRACK, /\A(\])/], [:LBRACE, /\A(\{)/], [:RBRACE, /\A(\})/], [:LPAREN, /\A(\()/], [:RPAREN, /\A(\))/], [:ISEQUAL, /\A(==)/], [:MATCH, /\A(=~)/], [:FARROW, /\A(=>)/], [:EQUALS, /\A(=)/], [:APPENDS, /\A(\+=)/], [:PARROW, /\A(\+>)/], [:PLUS, /\A(\+)/], [:GREATEREQUAL, /\A(>=)/], [:RSHIFT, /\A(>>)/], [:GREATERTHAN, /\A(>)/], [:LESSEQUAL, /\A(<=)/], [:LLCOLLECT, /\A(<<\|)/], [:OUT_EDGE, /\A(<-)/], [:OUT_EDGE_SUB, /\A(<~)/], [:LCOLLECT, /\A(<\|)/], [:LSHIFT, /\A(<<)/], [:LESSTHAN, /\A(<)/], [:NOMATCH, /\A(!~)/], [:NOTEQUAL, /\A(!=)/], [:NOT, /\A(!)/], [:RRCOLLECT, /\A(\|>>)/], [:RCOLLECT, /\A(\|>)/], [:IN_EDGE, /\A(->)/], [:IN_EDGE_SUB, /\A(~>)/], [:MINUS, /\A(-)/], [:COMMA, /\A(,)/], [:DOT, /\A(\.)/], [:COLON, /\A(:)/], [:AT, /\A(@)/], [:SEMIC, /\A(;)/], [:QMARK, /\A(\?)/], [:BACKSLASH, /\A(\\)/], [:TIMES, /\A(\*)/], [:MODULO, /\A(%)/], [:PIPE, /\A(\|)/], ] | Internal: An Array of Arrays containing tokens that can be described by a single regular expression. Each sub-Array contains 2 elements, the name of the token as a Symbol and a regular expression describing the value of the token. | |
FORMATTING_TOKENS | = | { :WHITESPACE => true, :NEWLINE => true, :COMMENT => true, :MLCOMMENT => true, :SLASH_COMMENT => true, :INDENT => true, } | Internal: A Hash whose keys are Symbols representing token types which are considered to be formatting tokens (i.e. tokens that don‘t contain code). |
Internal: Split a string on multiple terminators, excluding escaped terminators.
string - The String to be split. terminators - The String of terminators that the String should be split
on.
Returns an Array consisting of two Strings, the String up to the first terminator and the terminator that was found.
Internal: Tokenise the contents of a double quoted string.
string - The String to be tokenised. line - The Integer line number of the start of the passed string. column - The Integer column number of the start of the passed string.
Returns nothing.
Internal: Create a new PuppetLint::Lexer::Token object, calculate its line number and column and then add it to the Linked List of tokens.
type - The Symbol token type. value - The token value. length - The Integer length of the token‘s value. opts - A Hash of additional values required to determine line number and
column: :line - The Integer line number if calculated externally. :column - The Integer column number if calculated externally.
Returns the instantiated PuppetLint::Lexer::Token object.
Internal: Given the tokens already processed, determine if the next token could be a regular expression.
Returns true if the next token could be a regex, otherwise return false.
Internal: Convert a Puppet manifest into tokens.
code - The Puppet manifest to be tokenised as a String.
Returns an Array of PuppetLint::Lexer::Token objects. Raises PuppetLint::LexerError if it encounters unexpected characters (usually the result of syntax errors).