package core:odin/tokenizer

Types

Error_Handler ¶

Error_Handler :: proc "odin" (pos: Pos, fmt: string, args: ..any)

Flag ¶

Flag :: enum int {
	Insert_Semicolon, 
}

Flags ¶

Flags :: distinct bit_set[Flag; u32]

Pos ¶

Pos :: struct {
	file:   string,
	offset: int,
	// starting at 0
	line:   int,
	// starting at 1
	column: int,
}

Token ¶

Token :: struct {
	kind: Token_Kind,
	text: string,
	pos:  Pos,
}

Token_Kind ¶

Token_Kind :: enum u32 {
	Invalid, 
	EOF, 
	Comment, 
	B_Literal_Begin, 
	Ident,                        // main
	Integer,                      // 12345
	Float,                        // 123.45
	Imag,                         // 123.45i
	Rune,                         // 'a'
	String,                       // "abc"
	B_Literal_End, 
	B_Operator_Begin, 
	Eq,                           // =
	Not,                          // !
	Hash,                         // #
	At,                           // @
	Dollar,                       // $
	Pointer,                      // ^
	Question,                     // ?
	Add, 
	Sub,                          // -
	Mul,                          // *
	Quo,                          // /
	Mod,                          // %
	Mod_Mod,                      // %%
	And,                          // &
	Or,                           // |
	Xor,                          // ~
	And_Not,                      // &~
	Shl,                          // <<
	Shr,                          // >>
	Cmp_And,                      // &&
	Cmp_Or,                       // ||
	B_Assign_Op_Begin, 
	Add_Eq, 
	Sub_Eq,                       // -=
	Mul_Eq,                       // *=
	Quo_Eq,                       // /=
	Mod_Eq,                       // %=
	Mod_Mod_Eq,                   // %%=
	And_Eq,                       // &=
	Or_Eq,                        // |=
	Xor_Eq,                       // ~=
	And_Not_Eq,                   // &~=
	Shl_Eq,                       // <<=
	Shr_Eq,                       // >>=
	Cmp_And_Eq,                   // &&=
	Cmp_Or_Eq,                    // ||=
	B_Assign_Op_End, 
	Increment, 
	Decrement,                    // --
	Arrow_Right,                  // ->
	Undef,                        // ---
	B_Comparison_Begin, 
	Cmp_Eq,                       // ==
	Not_Eq,                       // !=
	Lt,                           // <
	Gt,                           // >
	Lt_Eq,                        // <=
	Gt_Eq,                        // >=
	B_Comparison_End, 
	Open_Paren,                   // (
	Close_Paren,                  // )
	Open_Bracket,                 // [
	Close_Bracket,                // ]
	Open_Brace,                   // {
	Close_Brace,                  // }
	Colon,                        // :
	Semicolon,                    // ;
	Period,                       // .
	Comma,                        // ,
	Ellipsis,                     // ..
	Range_Half,                   // ..<
	Range_Full,                   // ..=
	B_Operator_End, 
	B_Keyword_Begin, 
	Import,                       // import
	Foreign,                      // foreign
	Package,                      // package
	Typeid,                       // typeid
	When,                         // when
	Where,                        // where
	If,                           // if
	Else,                         // else
	For,                          // for
	Switch,                       // switch
	In,                           // in
	Not_In,                       // not_in
	Do,                           // do
	Case,                         // case
	Break,                        // break
	Continue,                     // continue
	Fallthrough,                  // fallthrough
	Defer,                        // defer
	Return,                       // return
	Proc,                         // proc
	Struct,                       // struct
	Union,                        // union
	Enum,                         // enum
	Bit_Set,                      // bit_set
	Map,                          // map
	Dynamic,                      // dynamic
	Auto_Cast,                    // auto_cast
	Cast,                         // cast
	Transmute,                    // transmute
	Distinct,                     // distinct
	Using,                        // using
	Context,                      // context
	Or_Else,                      // or_else
	Or_Return,                    // or_return
	Asm,                          // asm
	Inline,                       // inline
	No_Inline,                    // no_inline
	Matrix,                       // matrix
	B_Keyword_End, 
	COUNT, 
	B_Custom_Keyword_Begin = 116, 
}

Tokenizer ¶

Tokenizer :: struct {
	// Immutable data
	path:             string,
	src:              string,
	err:              Error_Handler,
	flags:            Flags,
	// Tokenizing state
	ch:               rune,
	offset:           int,
	read_offset:      int,
	line_offset:      int,
	line_count:       int,
	insert_semicolon: bool,
	// Mutable data
	error_count:      int,
}

Constants

This section is empty.

Variables

custom_keyword_tokens ¶

custom_keyword_tokens: []string

tokens ¶

tokens: [115]string = …

Procedures

advance_rune ¶

advance_rune :: proc "odin" (using t: ^Tokenizer) {…}

default_error_handler ¶

default_error_handler :: proc "odin" (pos: Pos, fmt: string, args: ..any) {…}

digit_val ¶

digit_val :: proc "odin" (r: rune) -> int {…}

error ¶

error :: proc "odin" (t: ^Tokenizer, offset: int, msg: string, args: ..any) {…}

init ¶

init :: proc "odin" (t: ^Tokenizer, src: string, path: string, err: Error_Handler = default_error_handler) {…}

is_assignment_operator ¶

is_assignment_operator :: proc "odin" (kind: Token_Kind) -> bool {…}

is_digit ¶

is_digit :: proc "odin" (r: rune) -> bool {…}

is_keyword ¶

is_keyword :: proc "odin" (kind: Token_Kind) -> bool {…}

is_letter ¶

is_letter :: proc "odin" (r: rune) -> bool {…}

is_literal ¶

is_literal :: proc "odin" (kind: Token_Kind) -> bool {…}

is_newline ¶

is_newline :: proc "odin" (tok: Token) -> bool {…}

is_operator ¶

is_operator :: proc "odin" (kind: Token_Kind) -> bool {…}

peek_byte ¶

peek_byte :: proc "odin" (t: ^Tokenizer, offset: int = 0) -> u8 {…}

pos_compare ¶

pos_compare :: proc "odin" (lhs, rhs: Pos) -> int {…}

scan ¶

scan :: proc "odin" (using t: ^Tokenizer) -> Token {…}

scan_comment ¶

scan_comment :: proc "odin" (using t: ^Tokenizer) -> string {…}

scan_escape ¶

scan_escape :: proc "odin" (using t: ^Tokenizer) -> bool {…}

scan_identifier ¶

scan_identifier :: proc "odin" (using t: ^Tokenizer) -> string {…}

scan_number ¶

scan_number :: proc "odin" (t: ^Tokenizer, seen_decimal_point: bool) -> (Token_Kind, string) {…}

scan_raw_string ¶

scan_raw_string :: proc "odin" (using t: ^Tokenizer) -> string {…}

scan_rune ¶

scan_rune :: proc "odin" (using t: ^Tokenizer) -> string {…}

scan_string ¶

scan_string :: proc "odin" (using t: ^Tokenizer) -> string {…}

skip_whitespace ¶

skip_whitespace :: proc "odin" (using t: ^Tokenizer) {…}

to_string ¶

to_string :: proc "odin" (kind: Token_Kind) -> string {…}

token_to_string ¶

token_to_string :: proc "odin" (tok: Token) -> string {…}

Procedure Groups

This section is empty.

Source Files

Generation Information

Generated with odin version dev-2022-10 (vendor "odin") Windows_amd64 @ 2022-10-05 21:11:47.476800300 +0000 UTC