package core:odin/printer

Types

Alignment_Style ¶

Alignment_Style :: enum int {
	Align_On_Type_And_Equals, 
	Align_On_Colon_And_Equals, 
}

Block_Type ¶

Block_Type :: enum int {
	None, 
	If_Stmt, 
	Proc, 
	Generic, 
	Comp_Lit, 
	Switch_Stmt, 
}

Brace_Style ¶

Brace_Style :: enum int {
	_1TBS, 
	Allman, 
	Stroustrup, 
	K_And_R, 
}

Config ¶

Config :: struct {
	spaces:               int,
	// Spaces per indentation
	newline_limit:        int,
	// The limit of newlines between statements and declarations.
	tabs:                 bool,
	// Enable or disable tabs
	convert_do:           bool,
	// Convert all do statements to brace blocks
	semicolons:           bool,
	// Enable semicolons
	split_multiple_stmts: bool,
	align_switch:         bool,
	brace_style:          Brace_Style,
	align_assignments:    bool,
	align_structs:        bool,
	align_style:          Alignment_Style,
	align_enums:          bool,
	align_length_break:   int,
	indent_cases:         bool,
	newline_style:        Newline_Style,
}

Format_Token ¶

Format_Token :: struct {
	kind:            odin_tokenizer.Token_Kind,
	text:            string,
	type:            Type_Enum,
	spaces_before:   int,
	parameter_count: int,
}
 

Represents a singular token in a unwrapped line

Line ¶

Line :: struct {
	format_tokens: [dynamic]Format_Token,
	finalized:     bool,
	used:          bool,
	depth:         int,
	types:         bit_set[Type_Enum],
}
 

Represents an unwrapped line

Line_Type ¶

Line_Type :: bit_set[Type_Enum]

List_Option ¶

List_Option :: enum u8 {
	Add_Comma, 
	Trailing, 
	Enforce_Newline, 
	Enforce_Poly_Names, 
}

List_Options ¶

List_Options :: distinct bit_set[List_Option]

Newline_Style ¶

Newline_Style :: enum int {
	CRLF, 
	LF, 
}

Printer ¶

Printer :: struct {
	string_builder:       strings.Builder,
	config:               Config,
	depth:                int,
	// the identation depth
	comments:             [dynamic]^odin_ast.Comment_Group,
	latest_comment_index: int,
	allocator:            runtime.Allocator,
	file:                 ^odin_ast.File,
	source_position:      odin_tokenizer.Pos,
	last_source_position: odin_tokenizer.Pos,
	lines:                [dynamic]Line,
	// need to look into a better data structure, one that can handle inserting lines rather than appending
	skip_semicolon:       bool,
	current_line:         ^Line,
	current_line_index:   int,
	last_line_index:      int,
	last_token:           ^Format_Token,
	merge_next_token:     bool,
	space_next_token:     bool,
	debug:                bool,
}

Type_Enum ¶

Type_Enum :: enum int {
	Line_Comment, 
	Value_Decl, 
	Switch_Stmt, 
	Struct, 
	Assign, 
	Call, 
	Enum, 
	If, 
	For, 
	Proc_Lit, 
}

Constants

This section is empty.

Variables

default_style ¶

default_style: Config = …

Procedures

align_comments ¶

align_comments :: proc "odin" (p: ^Printer) {…}

align_enum ¶

align_enum :: proc "odin" (p: ^Printer, index: int) {…}

align_struct ¶

align_struct :: proc "odin" (p: ^Printer, index: int) -> int {…}

align_switch_stmt ¶

align_switch_stmt :: proc "odin" (p: ^Printer, index: int) {…}

align_var_decls ¶

align_var_decls :: proc "odin" (p: ^Printer) {…}

find_last_token ¶

find_last_token :: proc "odin" (format_tokens: [dynamic]Format_Token) -> Format_Token {…}

fix_lines ¶

fix_lines :: proc "odin" (p: ^Printer) {…}

format_assignment ¶

format_assignment :: proc "odin" (p: ^Printer, index: int) {…}

format_call ¶

format_call :: proc "odin" (p: ^Printer, line_index: int, format_index: int) {…}

format_generic ¶

format_generic :: proc "odin" (p: ^Printer) {…}

format_keyword_to_brace ¶

format_keyword_to_brace :: proc "odin" (p: ^Printer, line_index: int, format_index: int, keyword: odin_tokenizer.Token_Kind) {…}

format_value_decl ¶

format_value_decl :: proc "odin" (p: ^Printer, index: int) {…}

make_printer ¶

make_printer :: proc "odin" (config: Config, allocator := context.allocator) -> Printer {…}

print ¶

print :: proc "odin" (p: ^Printer, file: ^odin_ast.File) -> string {…}

visit_begin_brace ¶

visit_begin_brace :: proc "odin" (p: ^Printer, begin: odin_tokenizer.Pos, type: Block_Type, count: int = 0, same_line_spaces_before: int = 1) {…}

visit_binary_expr ¶

visit_binary_expr :: proc "odin" (p: ^Printer, binary: ^odin_ast.Binary_Expr) {…}

visit_block_stmts ¶

visit_block_stmts :: proc "odin" (p: ^Printer, stmts: []^odin_ast.Stmt, split: bool = false) {…}

visit_call_exprs ¶

visit_call_exprs :: proc "odin" (p: ^Printer, list: []^odin_ast.Expr, ellipsis: bool = false) {…}

visit_end_brace ¶

visit_end_brace :: proc "odin" (p: ^Printer, end: odin_tokenizer.Pos) {…}

visit_field_list ¶

visit_field_list :: proc "odin" (p: ^Printer, list: ^odin_ast.Field_List, options: List_Options = List_Options{}) {…}

visit_proc_type ¶

visit_proc_type :: proc "odin" (p: ^Printer, proc_type: ^odin_ast.Proc_Type, is_proc_lit: bool = false) {…}

visit_signature_list ¶

visit_signature_list :: proc "odin" (p: ^Printer, list: ^odin_ast.Field_List, remove_blank: bool = true) {…}

Procedure Groups

This section is empty.

Source Files

Generation Information

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