Class: Rouge::Lexers::Javascript
- Inherits:
-
RegexLexer
- Object
- Rouge::Lexer
- RegexLexer
- Rouge::Lexers::Javascript
- Defined in:
- lib/rouge/lexers/javascript.rb
Overview
IMPORTANT NOTICE:
Please do not copy this lexer and open a pull request for a new language. It will not get merged, you will be unhappy, and kittens will cry.
Direct Known Subclasses
JSX, Qml, Typescript
Constant Summary
Constants inherited from RegexLexer
Constants included from Token::Tokens
Token::Tokens::Num, Token::Tokens::Str
Instance Attribute Summary
Attributes inherited from Rouge::Lexer
Class Method Summary collapse
- .builtins ⇒ Object
- .constants ⇒ Object
- .declarations ⇒ Object
-
.detect?(text) ⇒ Boolean
Pseudo-documentation: stackoverflow.com/questions/1661197/what-characters-are-valid-for-javascript-variable-names.
- .id_regex ⇒ Object
- .keywords ⇒ Object
- .reserved ⇒ Object
Methods inherited from RegexLexer
append, #delegate, get_state, #get_state, #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, assert_utf8!, #bool_option, continue_lex, #continue_lex, debug_enabled?, demo, demo_file, desc, 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
Constructor Details
This class inherits a constructor from Rouge::Lexer
Class Method Details
.builtins ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/rouge/lexers/javascript.rb', line 127 def self.builtins @builtins ||= %w( Array Boolean Date Error Function Math netscape Number Object Packages RegExp String sun decodeURI decodeURIComponent encodeURI encodeURIComponent Error eval isFinite isNaN parseFloat parseInt document window navigator self global Promise Set Map WeakSet WeakMap Symbol Proxy Reflect Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Uint16ClampedArray Int32Array Uint32Array Uint32ClampedArray Float32Array Float64Array DataView ArrayBuffer ) end |
.constants ⇒ Object
123 124 125 |
# File 'lib/rouge/lexers/javascript.rb', line 123 def self.constants @constants ||= Set.new %w(true false null NaN Infinity undefined) end |
.declarations ⇒ Object
109 110 111 112 113 114 |
# File 'lib/rouge/lexers/javascript.rb', line 109 def self.declarations @declarations ||= Set.new %w( var let const with function class extends constructor get set static ) end |
.detect?(text) ⇒ Boolean
24 25 26 27 28 |
# File 'lib/rouge/lexers/javascript.rb', line 24 def self.detect?(text) return 1 if text.shebang?('node') return 1 if text.shebang?('jsc') # TODO: rhino, spidermonkey, etc end |
.id_regex ⇒ Object
142 143 144 |
# File 'lib/rouge/lexers/javascript.rb', line 142 def self.id_regex /[\p{L}\p{Nl}$_][\p{Word}]*/io end |
.keywords ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/rouge/lexers/javascript.rb', line 101 def self.keywords @keywords ||= Set.new %w( async await break case catch continue debugger default delete do else export finally from for if import in instanceof new of return super switch this throw try typeof void while yield ) end |
.reserved ⇒ Object
116 117 118 119 120 121 |
# File 'lib/rouge/lexers/javascript.rb', line 116 def self.reserved @reserved ||= Set.new %w( enum implements interface package private protected public ) end |