v.token #

Constants #

const (
	assign_tokens = [Kind.assign, .plus_assign, .minus_assign, .mult_assign, .div_assign, .xor_assign,
		.mod_assign, .or_assign, .and_assign, .right_shift_assign, .left_shift_assign]
)
const (
	valid_at_tokens = ['@FN', '@METHOD', '@MOD', '@STRUCT', '@VEXE', '@FILE', '@LINE', '@COLUMN',
		'@VHASH', '@VMOD_FILE']
)
const (
	keywords = build_keys()
)

fn build_precedences #

fn build_precedences() []Precedence

fn is_decl #

fn is_decl(t Kind) bool

fn is_key #

fn is_key(key string) bool

fn key_to_token #

fn key_to_token(key string) Kind

enum AtKind #

enum AtKind {
	unknown
	fn_name
	method_name
	mod_name
	struct_name
	vexe_path
	file_path
	line_nr
	column_nr
	vhash
	vmod_file
}

@FN => will be substituted with the name of the current V function @METHOD => will be substituted with ReceiverType.MethodName @MOD => will be substituted with the name of the current V module @STRUCT => will be substituted with the name of the current V struct @VEXE => will be substituted with the path to the V compiler @FILE => will be substituted with the path of the V source file @LINE => will be substituted with the V line number where it appears (as a string). @COLUMN => will be substituted with the column where it appears (as a string). @VHASH => will be substituted with the shortened commit hash of the V compiler (as a string). @VMOD_FILE => will be substituted with the contents of the nearest v.mod file (as a string). This allows things like this: println( 'file: ' + @FILE + ' | line: ' + @LINE + ' | fn: ' + @MOD + '.' + @FN) ... which is useful while debugging/tracing @VROOT is special and handled in places like '#include ...' @<type> is allowed for keyword variable names. E.g. 'type'

enum Kind #

enum Kind {
	unknown
	eof
	name
	number
	string
	str_inter
	chartoken
	plus
	minus
	mul
	div
	mod
	xor
	pipe
	inc
	dec
	and
	logical_or
	not
	bit_not
	question
	comma
	semicolon
	colon
	arrow
	amp
	hash
	dollar
	at
	str_dollar
	left_shift
	right_shift
	not_in
	not_is
	assign
	decl_assign
	plus_assign
	minus_assign
	div_assign
	mult_assign
	xor_assign
	mod_assign
	or_assign
	and_assign
	right_shift_assign
	left_shift_assign
	lcbr
	rcbr
	lpar
	rpar
	lsbr
	rsbr
	eq
	ne
	gt
	lt
	ge
	le
	comment
	nl
	dot
	dotdot
	ellipsis
	keyword_beg
	key_as
	key_asm
	key_assert
	key_atomic
	key_break
	key_const
	key_continue
	key_defer
	key_else
	key_enum
	key_false
	key_for
	key_fn
	key_global
	key_go
	key_goto
	key_if
	key_import
	key_in
	key_interface
	key_is
	key_match
	key_module
	key_mut
	key_shared
	key_lock
	key_rlock
	key_none
	key_return
	key_select
	key_sizeof
	key_likely
	key_unlikely
	key_offsetof
	key_struct
	key_true
	key_type
	key_typeof
	key_dump
	key_orelse
	key_union
	key_pub
	key_static
	key_unsafe
	keyword_end
	_end_
}

fn (Kind) is_assign #

fn (t Kind) is_assign() bool

fn (Kind) str #

fn (t Kind) str() string

note: used for some code generation, so no quoting

fn (Kind) is_relational #

fn (tok Kind) is_relational() bool

fn (Kind) is_start_of_type #

fn (k Kind) is_start_of_type() bool

fn (Kind) is_prefix #

fn (kind Kind) is_prefix() bool

fn (Kind) is_infix #

fn (kind Kind) is_infix() bool

enum Precedence #

enum Precedence {
	lowest
	cond
	in_as
	assign
	eq
	sum
	product
	prefix
	postfix
	call
	index
}

Representation of highest and lowest precedence

struct Position #

struct Position {
pub:
	len     int
	line_nr int
	pos     int
	col     int
pub mut:
	last_line int
}

fn (Position) str #

fn (pos Position) str() string

fn (Position) extend #

fn (pos Position) extend(end Position) Position

fn (Position) extend_with_last_line #

fn (pos Position) extend_with_last_line(end Position, last_line int) Position

fn (Position) update_last_line #

fn (mut pos Position) update_last_line(last_line int)

struct Token #

struct Token {
pub:
	kind    Kind
	lit     string
	line_nr int
	col     int

	pos  int
	len  int
	tidx int
}

fn (Token) can_start_type #

fn (tok &Token) can_start_type(builtin_type_names []string) bool

Pass ast.builtin_type_names Note: can't import table here due to circular module dependency

fn (Token) is_scalar #

fn (tok Token) is_scalar() bool

is_scalar returns true if the token is a scalar

fn (Token) is_unary #

fn (tok Token) is_unary() bool

is_unary returns true if the token can be in a unary expression

fn (Token) position #

fn (tok &Token) position() Position

fn (Token) precedence #

fn (tok Token) precedence() int

precedence returns a tokens precedence if defined, otherwise lowest_prec

fn (Token) str #

fn (t Token) str() string