Class: Rouge::Lexers::Go

Inherits:
RegexLexer show all
Defined in:
lib/rouge/lexers/go.rb

Constant Summary collapse

WHITE_SPACE =

Characters

/\s+/
NEWLINE =
/\n/
UNICODE_CHAR =
/[^\n]/
UNICODE_LETTER =
/[[:alpha:]]/
UNICODE_DIGIT =
/[[:digit:]]/
LETTER =

Letters and digits

/#{UNICODE_LETTER}|_/
DECIMAL_DIGIT =
/[0-9]/
OCTAL_DIGIT =
/[0-7]/
HEX_DIGIT =
/[0-9A-Fa-f]/
LINE_COMMENT =

Comments

/\/\/(?:(?!#{NEWLINE}).)*/
GENERAL_COMMENT =
/\/\*(?:(?!\*\/).)*\*\//m
COMMENT =
/#{LINE_COMMENT}|#{GENERAL_COMMENT}/
KEYWORD =

Keywords

/\b(?:
  break       | default     | func
| interface   | select      | case
| defer       | go          | map
| struct      | chan        | else
| goto        | package     | switch
| const       | fallthrough | if
| range       | type        | continue
| for         | import      | return
| var
)\b/x
IDENTIFIER =

Identifiers

/ (?!#{KEYWORD})
#{LETTER}(?:#{LETTER}|#{UNICODE_DIGIT})* /x
OPERATOR =

Operators and delimiters

/ \+=    | \+\+   | \+     | &\^=   | &\^
| &=     | &&     | &      | ==     | =
| \!=    | \!     | -=     | --     | -
| \|=    | \|\|   | \|     | <=     | <-
| <<=    | <<     | <      | \*=    | \*
| \^=    | \^     | >>=    | >>     | >=
| >      | \/     | \/=    | :=     | %
| %=     | \.\.\. | \.     | :
/x
SEPARATOR =
/ \(     | \)     | \[     | \]     | \{
| \}     | ,      | ;
/x
DECIMAL_LIT =

Integer literals

/[0-9]#{DECIMAL_DIGIT}*/
OCTAL_LIT =
/0#{OCTAL_DIGIT}*/
HEX_LIT =
/0[xX]#{HEX_DIGIT}+/
INT_LIT =
/#{HEX_LIT}|#{DECIMAL_LIT}|#{OCTAL_LIT}/
DECIMALS =

Floating-point literals

/#{DECIMAL_DIGIT}+/
EXPONENT =
/[eE][+\-]?#{DECIMALS}/
FLOAT_LIT =
/ #{DECIMALS} \. #{DECIMALS}? #{EXPONENT}?
| #{DECIMALS} #{EXPONENT}
| \. #{DECIMALS} #{EXPONENT}?
/x
IMAGINARY_LIT =

Imaginary literals

/(?:#{DECIMALS}|#{FLOAT_LIT})i/
ESCAPED_CHAR =

Rune literals

/\\[abfnrtv\\'"]/
LITTLE_U_VALUE =
/\\u#{HEX_DIGIT}{4}/
BIG_U_VALUE =
/\\U#{HEX_DIGIT}{8}/
UNICODE_VALUE =
/ #{UNICODE_CHAR} | #{LITTLE_U_VALUE}
| #{BIG_U_VALUE}  | #{ESCAPED_CHAR}
/x
OCTAL_BYTE_VALUE =
/\\#{OCTAL_DIGIT}{3}/
HEX_BYTE_VALUE =
/\\x#{HEX_DIGIT}{2}/
BYTE_VALUE =
/#{OCTAL_BYTE_VALUE}|#{HEX_BYTE_VALUE}/
CHAR_LIT =
/'(?:#{UNICODE_VALUE}|#{BYTE_VALUE})'/
ESCAPE_SEQUENCE =
/ #{ESCAPED_CHAR}
| #{LITTLE_U_VALUE}
| #{BIG_U_VALUE}
| #{HEX_BYTE_VALUE}
/x
RAW_STRING_LIT =

String literals

/`(?:#{UNICODE_CHAR}|#{NEWLINE})*`/
INTERPRETED_STRING_LIT =
/ "(?: (?!")
    (?: #{UNICODE_VALUE} | #{BYTE_VALUE} )
)*" /x
STRING_LIT =
/#{RAW_STRING_LIT}|#{INTERPRETED_STRING_LIT}/
PREDECLARED_TYPES =

Predeclared identifiers

/\b(?:
   bool       | byte       | complex64
 | complex128 | error      | float32
 | float64    | int8       | int16
 | int32      | int64      | int
 | rune       | string     | uint8
 | uint16     | uint32     | uint64
 | uintptr    | uint
)\b/x
PREDECLARED_CONSTANTS =
/\b(?:true|false|iota|nil)\b/
PREDECLARED_FUNCTIONS =
/\b(?:
  append  | cap     | close   | complex
| copy    | delete  | imag    | len
| make    | new     | panic   | print
| println | real    | recover
)\b/x

Constants inherited from RegexLexer

RegexLexer::MAX_NULL_SCANS

Constants included from Token::Tokens

Token::Tokens::Num, Token::Tokens::Str

Instance Attribute Summary

Attributes inherited from Rouge::Lexer

#options

Method Summary

Methods inherited from RegexLexer

append, #delegate, #goto, #group, #groups, #in_state?, #pop!, prepend, #push, #recurse, replace_state, #reset!, #reset_stack, #stack, start, start_procs, state, #state, #state?, state_definitions, states, #step, #stream_tokens, #token

Methods inherited from Rouge::Lexer

aliases, all, #as_bool, #as_lexer, #as_list, #as_string, #as_token, #bool_option, continue_lex, #continue_lex, debug_enabled?, demo, demo_file, desc, detect?, detectable?, disable_debug!, enable_debug!, filenames, find, find_fancy, guess, guess_by_filename, guess_by_mimetype, guess_by_source, guesses, #hash_option, #initialize, lex, #lex, #lexer_option, #list_option, lookup_fancy, mimetypes, option, option_docs, #reset!, #stream_tokens, #string_option, tag, #tag, title, #token_option, #with

Methods included from Token::Tokens

token

Constructor Details

This class inherits a constructor from Rouge::Lexer