package core:text/regex/parser

⌘K
Ctrl+K
or
/

    Overview

    package regex_parser implements a Pratt parser, also known as a Top-Down Operator Precedence parser, for parsing tokenized regular expression patterns.

    References: https://dl.acm.org/doi/10.1145/512927.512931 https://tdop.github.io/ http://crockford.com/javascript/tdop/tdop.html

    Types

    Expected_Token ¶

    Expected_Token :: struct {
    	pos:  int,
    	kind: regex_tokenizer.Token_Kind,
    }

    Invalid_Repetition ¶

    Invalid_Repetition :: struct {
    	pos: int,
    }

    Invalid_Token ¶

    Invalid_Token :: struct {
    	pos:  int,
    	kind: regex_tokenizer.Token_Kind,
    }

    Invalid_Unicode ¶

    Invalid_Unicode :: struct {
    	pos: int,
    }

    Node_Alternation ¶

    Node_Alternation :: struct {
    	left:  Node,
    	right: Node,
    }

    Node_Anchor ¶

    Node_Anchor :: struct {
    	start: bool,
    }

    Node_Concatenation ¶

    Node_Concatenation :: struct {
    	nodes: [dynamic]Node,
    }

    Node_Group ¶

    Node_Group :: struct {
    	inner:      Node,
    	capture_id: int,
    	capture:    bool,
    }

    Node_Match_All_And_Escape ¶

    Node_Match_All_And_Escape :: struct {}

    Node_Optional ¶

    Node_Optional :: struct {
    	inner: Node,
    }

    Node_Optional_Non_Greedy ¶

    Node_Optional_Non_Greedy :: struct {
    	inner: Node,
    }

    Node_Repeat_N ¶

    Node_Repeat_N :: struct {
    	inner: Node,
    	lower: int,
    	upper: int,
    }

    Node_Repeat_One ¶

    Node_Repeat_One :: struct {
    	inner: Node,
    }

    Node_Repeat_One_Non_Greedy ¶

    Node_Repeat_One_Non_Greedy :: struct {
    	inner: Node,
    }

    Node_Repeat_Zero ¶

    Node_Repeat_Zero :: struct {
    	inner: Node,
    }

    Node_Repeat_Zero_Non_Greedy ¶

    Node_Repeat_Zero_Non_Greedy :: struct {
    	inner: Node,
    }

    Node_Rune ¶

    Node_Rune :: struct {
    	data: rune,
    }

    Node_Rune_Class ¶

    Node_Rune_Class :: struct {
    	negating: bool,
    	using data: Rune_Class_Data,
    }

    Node_Wildcard ¶

    Node_Wildcard :: struct {}

    Node_Word_Boundary ¶

    Node_Word_Boundary :: struct {
    	non_word: bool,
    }

    Parser ¶

    Parser :: struct {
    	flags:     bit_set[regex_common.Flag; u8],
    	t:         regex_tokenizer.Tokenizer,
    	cur_token: regex_tokenizer.Token,
    	groups:    int,
    }
    Related Procedures With Parameters

    Rune_Class_Data ¶

    Rune_Class_Data :: struct {
    	runes:  [dynamic]rune,
    	ranges: [dynamic]Rune_Class_Range,
    }

    Rune_Class_Range ¶

    Rune_Class_Range :: struct {
    	lower: rune,
    	upper: rune,
    }

    Token ¶

    Token :: regex_tokenizer.Token

    Token_Kind ¶

    Token_Kind :: regex_tokenizer.Token_Kind

    Tokenizer ¶

    Tokenizer :: regex_tokenizer.Tokenizer

    Too_Many_Capture_Groups ¶

    Too_Many_Capture_Groups :: struct {
    	pos: int,
    }

    Unexpected_EOF ¶

    Unexpected_EOF :: struct {
    	pos: int,
    }

    Constants

    This section is empty.

    Variables

    This section is empty.

    Procedures

    advance ¶

    advance :: proc(p: ^Parser) -> Error {…}

    expect ¶

    expect :: proc(p: ^Parser, kind: regex_tokenizer.Token_Kind) -> (err: Error) {…}

    left_binding_power ¶

    left_binding_power :: proc(kind: regex_tokenizer.Token_Kind) -> int {…}

    left_denotation ¶

    left_denotation :: proc(p: ^Parser, token: regex_tokenizer.Token, left: Node) -> (result: Node, err: Error) {…}

    null_denotation ¶

    null_denotation :: proc(p: ^Parser, token: regex_tokenizer.Token) -> (result: Node, err: Error) {…}

    parse ¶

    parse :: proc(str: string, flags: bit_set[regex_common.Flag; u8]) -> (result: Node, err: Error) {…}

    parse_expression ¶

    parse_expression :: proc(p: ^Parser, rbp: int) -> (result: Node, err: Error) {…}

    write_node ¶

    write_node :: proc(w: io.Stream, node: Node) {…}

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2024-12 (vendor "odin") Windows_amd64 @ 2024-12-17 21:11:02.078568200 +0000 UTC