std::jule:lex
Globals
static Puncts: [...]rune
Punctuations.
static Spaces: [...]rune
Space characters.
static UnaryOps: [...]TokenKind
Kind list of unary operators.
static BinOps: [...]TokenKind
Kind list of binary operators.
static WeakOps: [...]TokenKind
Kind list of weak operators.
These operators are weak, can used as part of expression.
static PostfixOps: [...]TokenKind
List of postfix operators.
static AssignOps: [...]TokenKind
List of assign operators.
Functions
fn Lex(mut f: &File, text: []byte): bool
Lex source code into fileset.
Returns nil if f == nil
.
Returns nil slice for errors if no any error.
fn NewFileSet(path: str): &File
Returns new File points to Jule file.
fn IsUnaryOp(kind: str): bool
Reports whether kind is unary operator.
fn IsBinOp(kind: str): bool
Reports whether kind is binary operator.
fn IsWeakOp(kind: str): bool
Reports whether kind is weak operator.
fn IsStr(k: str): bool
Reports whether kind is string literal.
fn IsRawStr(k: str): bool
Reports whether kind is raw string literal.
fn IsRune(k: str): bool
Reports whether kind is rune literal. Literal value can be byte or rune.
fn IsNil(k: str): bool
Reports whether kind is nil literal.
fn IsBool(k: str): bool
Reports whether kind is boolean literal.
fn IsFloat(k: str): bool
Reports whether kind is float.
fn IsNum(k: str): bool
Reports whether kind is numeric.
fn IsLit(k: str): bool
Reports whether kind is literal.
fn IsIgnoreIdent(ident: str): bool
Reports whether identifier is ignore.
fn IsAnonIdent(ident: str): bool
Reports whether identifier is anonymous.
fn IsPunct(r: rune): bool
Reports whether rune is punctuation.
fn IsSpace(r: rune): bool
Reports wheter byte is whitespace.
fn IsLetter(r: rune): bool
Reports whether rune is letter.
fn IsIdentRune(s: str): bool
Reports whether firs rune of string is allowed to first rune for identifier.
fn IsDecimal(b: byte): bool
Reports whether byte is decimal sequence.
fn IsBinary(b: byte): bool
Reports whether byte is binary sequence.
fn IsOctal(b: byte): bool
Reports whether byte is octal sequence.
fn IsHex(b: byte): bool
Reports whether byte is hexadecimal sequence.
Structs
struct File {
Path: str
Data: []byte
Tokens: []&Token
}
Fileset for lexing.
Methods:
fn IsOk(self): bool
Reports whether file path is exist and accessible.
fn Dir(self): str
Returns directory of file's path.
fn Name(self): str
Returns filename.
fn Addr(self): uintptr
Returns self as uintptr.
fn Fill(mut self, mut data: []byte)
Fill data.
fn GetRow(self, row: int): str
Return line (not include new-line char) by row.
Returns empty string if line is not exist in buffer.
struct Token {
File: &File
Row: int
Column: int
Kind: str
Id: TokenId
}
Token is lexer token.
Methods:
fn Prec(self): byte
Returns operator precedence of token.
Returns 0
if token is not operator or
invalid operator for operator precedence.
Accepts assignment tokens (like equals [=]) as precedenced operator to handle expression assignments.
fn Path(self): str
Returns path.
fn Dir(self): str
Returns directory of file's path.
fn Name(self): str
Returns filename.
fn Addr(self): uintptr
Returns self as uintptr.
Enums
enum LexMode
Lexer mode.
Fields:
Standard
: Standard mode.Comment
: Standard mode + comments.
enum Idenet: str
Special identifiers.
Fields:
Ignore
: IgnoreAnon
: Anonymous
enum TokenId: uint
Token identities.
Fields:
Na
Prim
Ident
Range
Ret
Semicolon
Lit
Op
Comma
Const
Type
Colon
For
Break
Cont
In
If
Else
Comment
Use
Dot
Pub
Goto
DblColon
Enum
Struct
Co
Match
Self
Trait
Impl
Cpp
Fall
Fn
Let
Unsafe
Mut
Defer
Static
Error
enum TokenKind: str
Token kinds.
Fields:
DblColon
Colon
Semicolon
Comma
TripleDot
Dot
PlusEq
MinusEq
StarEq
SolidusEq
PercentEq
LshiftEq
RshiftEq
CaretEq
AmperEq
VlineEq
Eqs
NotEq
GreatEq
LessEq
DblAmper
DblVline
Lshift
Rshift
DblPlus
DblMinus
Plus
Minus
Star
Solidus
Percent
Amper
Vline
Caret
Excl
Lt
Gt
Eq
LnComment
RangLComment
RangRComment
LParent
RParent
LBracket
RBracket
LBrace
RBrace
I8
I16
I32
I64
U8
U16
U32
U64
Uint
Int
Uintptr
Bool
Str
Any
True
False
Nil
Const
Ret
Type
For
Break
Cont
In
If
Else
Use
Pub
Goto
Enum
Struct
Co
Match
Self
Trait
Impl
Cpp
Fall
Fn
Let
Unsafe
Mut
Defer
Static
Hash
Error