class JavaLexer

Defined in:

minilexers/java.cr

Constant Summary

ABSTRACT = "abstract"

Keywords

ADD = "+"
ADD_ASSIGN = "+="
AND = "&&"
AND_ASSIGN = "&="
ARROW = "->"

Java 8 tokens

ASSERT = "assert"
ASSIGN = "="

Operators

AT = "@"

Additional symbols not defined in the lexical specification

BANG = "!"
BINARY_LITERAL = /0[bB][01]([01_]*[01])?[lL]?/
BITAND = "&"
BITOR = "|"
BOOL_LITERAL = /true|false/
BOOLEAN = "boolean"
BREAK = "break"
BYTE = "byte"
CARET = "^"
CASE = "case"
CATCH = "catch"
CHAR = "char"
CHAR_LITERAL = /'([^'\\\r\n]|\\['"\\bfnrt]|\\u[0-9a-fA-F]{4}|\\[^'"\r\n])*'/
CLASS = "class"
COLON = ":"
COLONCOLON = "::"
COMMA = ","
COMMENT = /\/\*.*?\*\//m
CONST = "const"
CONTINUE = "continue"
DEC = "--"
DECIMAL_LITERAL = /0|[1-9]([_\d]*\d)?[lL]?/

Literals

DEFAULT = "default"
Digits = /\d([_\d]*\d)?/
DIV = "/"
DIV_ASSIGN = "/="
DO = "do"
DOT = "."
DOUBLE = "double"
ELLIPSIS = "..."
ELSE = "else"
ENUM = "enum"
EQUAL = "=="
EscapeSequence = /\\(?:u005c)?[btnfr"'\\]|\\u(?:[0-3]?[0-7])?[0-7]|\\u[0-9a-fA-F]{4}/
ExponentPart = /[eE][+-]?\d+/

Fragment rules

EXPORTS = "exports"
EXTENDS = "extends"
FINAL = "final"
FINALLY = "finally"
FLOAT = "float"
FLOAT_LITERAL = /((\d+\.\d*|\.\d+)([eE][+-]?\d+)?|[+-]?\d+[eE][+-]?\d+)[fFdD]?/
FOR = "for"
GE = ">="
GOTO = "goto"
GT = ">"
HEX_FLOAT_LITERAL = /0[xX]([0-9a-fA-F]+(\.[0-9a-fA-F]*)?|\.[0-9a-fA-F]+)[pP][+-]?\d+[fFdD]?/
HEX_LITERAL = /0[xX][0-9a-fA-F]([0-9a-fA-F_]*[0-9a-fA-F])?[lL]?/
HexDigit = /[0-9a-fA-F]/
HexDigits = /[0-9a-fA-F]([_0-9a-fA-F]*[0-9a-fA-F])?/
IDENTIFIER = /[a-zA-Z$_][a-zA-Z\d$_]*/

Identifiers

IF = "if"
IMPLEMENTS = "implements"
IMPORT = "import"
INC = "++"
INSTANCEOF = "instanceof"
INT = "int"
INTERFACE = "interface"
LBRACE = "{"
LBRACK = "["
LE = "<="
Letter = /[a-zA-Z$_]|[^[:ascii:]]/
LetterOrDigit = /[a-zA-Z\d$_]/
LINE_COMMENT = /\/\/[^\r\n]*/
LONG = "long"
LPAREN = "("

Separators

LSHIFT_ASSIGN = "<<="
LT = "<"
MOD = "%"
MOD_ASSIGN = "%="
MODULE = "module"

Module related keywords

MUL = "*"
MUL_ASSIGN = "*="
NATIVE = "native"
NEW = "new"
NON_SEALED = "non-sealed"
NOTEQUAL = "!="
NULL_LITERAL = "null"
OCT_LITERAL = /0[0-7]([0-7_]*[0-7])?[lL]?/
OPEN = "open"
OPENS = "opens"
OR = "||"
OR_ASSIGN = "|="
PACKAGE = "package"
PERMITS = "permits"
PRIVATE = "private"
PROTECTED = "protected"
PROVIDES = "provides"
PUBLIC = "public"
QUESTION = "?"
RBRACE = "}"
RBRACK = "]"
RECORD = "record"

Records

REQUIRES = "requires"
RETURN = "return"
RPAREN = ")"
RSHIFT_ASSIGN = ">>="
SEALED = "sealed"

Sealed Classes

SEMI = ";"
SHORT = "short"
STATIC = "static"
STRICTFP = "strictfp"
STRING_LITERAL = /"([^"\\\r\n]|\\["\\bfnrt]|\\u[0-9a-fA-F]{4}|\\[^"\r\n])*"/
SUB = "-"
SUB_ASSIGN = "-="
SUPER = "super"
SWITCH = "switch"
SYNCHRONIZED = "synchronized"
TEXT_BLOCK = /"""\s*(.|\\["\\bfnrt])*?\s*"""/
THIS = "this"
THROW = "throw"
THROWS = "throws"
TILDE = "~"
TO = "to"
TRANSIENT = "transient"
TRANSITIVE = "transitive"
TRY = "try"
URSHIFT_ASSIGN = ">>>="
USES = "uses"
VAR = "var"

Local Variable Type Inference

VOID = "void"
VOLATILE = "volatile"
WHILE = "while"
WITH = "with"
WS = /[ \t\r\n\x0C]+/

Whitespace and comments

XOR_ASSIGN = "^="
YIELD = "yield"

Switch Expressions

Constructors

Instance Method Summary

Instance methods inherited from class MiniLexer

<<(t : Tuple(Symbol, String))
<<(t : Tuple(Symbol, Char))
<<(t : Tuple(Symbol, Char | String))
<<
, find(token_type : Symbol) : Array(Token) find, line : Int line, mode : Symbol mode, mode=(mode : Symbol)
mode=(mode : Symbol)
mode=
, start_repl start_repl, tokenize(input : String) : Array(Token) tokenize, tokenize_logic(input : String) : Array(Token) tokenize_logic, tokens : Array(Token) tokens, tokens=(tokens : Array(Token)) tokens=, trace trace

Constructor methods inherited from class MiniLexer

new new

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def match_char_literal #

[View source]
def match_identifier_or_keyword #

[View source]
def match_number #

[View source]
def match_other #

[View source]
def match_string_literal_or_text_block #

[View source]
def skip_whitespace_and_comments #

[View source]
def tokenize(input : String) : Array(Token) #

[View source]
def tokenize_logic(input : String) : Array(Token) #

[View source]