kdl-hs-1.1.1: KDL language parser and API
Safe HaskellNone
LanguageGHC2021

KDL.Parser.Internal

Description

Implement the v2 parser specified at: https://kdl.dev/spec/#name-full-grammar

Synopsis

Documentation

data ParseConfig Source #

Constructors

ParseConfig 

Instances

Instances details
Default ParseConfig Source # 
Instance details

Defined in KDL.Parser.Internal

Methods

def :: ParseConfig #

(1) Compatibility

p_bom :: Parser () Source #

ref: (1) bom := 'u{FEFF}'

p_version :: Parser () Source #

ref: (1) version := /- unicode-space* 'kdl-version' unicode-space+ ('1' | '2') unicode-space* newline

(3.1) Document

p_document :: Parser Document Source #

ref: (3.1) document := bom? version? nodes

p_nodes :: Parser NodeList Source #

ref: (3.1) nodes := (line-space* node)* line-space*

p_line_space :: Parser () Source #

ref: (3.1) + (3.17) // Whitespace where newlines are allowed. line-space := node-space | newline | single-line-comment

p_node_space :: Parser () Source #

ref: (3.1) + (3.17) // Whitespace within nodes, // where newline-ish things must be esclined. node-space := ws* escline ws* | ws+

(3.2) Node

p_node :: Parser (SlashdashResult, Parser (Node, Bool)) Source #

ref: (3.2) node := base-node node-terminator final-node := base-node node-terminator?

p_base_node :: Parser (SlashdashResult, Parser Node) Source #

ref: (3.2) base-node := slashdash? type? node-space* string (node-space* (node-space | slashdash) node-prop-or-arg)* // slashdashed node-children must always be after props and args. (node-space* slashdash node-children)* (node-space* node-children)? (node-space* slashdash node-children)* node-space*

p_node_prop_or_arg :: Parser Entry Source #

ref: (3.2) node-prop-or-arg := prop | value

p_node_terminator :: Parser Text Source #

ref: (3.2) node-terminator := single-line-comment | newline | ';' | eof

(3.3) Line Continuation

p_escline :: Parser () Source #

ref: (3.3) escline := \\ ws* (single-line-comment | newline | eof)

(3.4) Property

p_prop :: Parser Entry Source #

ref: (3.4) prop := string node-space* '=' node-space* value

(3.5) Argument

(3.6) Children Block

p_node_children :: Parser NodeList Source #

ref: (3.6) node-children := '{' nodes final-node? '}'

(3.7) Value

p_value :: Parser (Value, Text) Source #

ref: (3.7) value := type? node-space* (string | number | keyword)

(3.8) Type Annotation

p_type :: Parser Ann Source #

ref: (3.8) type := '(' node-space* string node-space* ')'

(3.9) String

p_string :: Parser Text Source #

ref: (3.9) string := identifier-string | quoted-string | raw-string ¶

(3.10) Identifier String

p_identifier_string :: Parser Text Source #

ref: (3.10) identifier-string := unambiguous-ident | signed-ident | dotted-ident

p_unambiguous_ident :: Parser Text Source #

ref: (3.10) unambiguous-ident := ((identifier-char - digit - sign - .) identifier-char*) - disallowed-keyword-identifiers

p_signed_ident :: Parser Text Source #

ref: (3.10) signed-ident := sign ((identifier-char - digit - .) identifier-char*)?

disallowed_keyword_identifiers :: Set Text Source #

ref: (3.10) disallowed-keyword-identifiers := true | false | null | inf | '-inf' | nan

p_dotted_ident :: Parser Text Source #

ref: (3.10) dotted-ident := sign? . ((identifier-char - digit) identifier-char*)?

p_identifier_char :: Parser Char Source #

ref: (3.10.2) identifier-char := unicode - unicode-space - newline - [\/(){};[]"#=] - disallowed-literal-code-points

(3.11) Quoted String

p_quoted_string :: Parser Text Source #

ref: (3.11) + (3.12) quoted-string := '"' single-line-string-body '"' | '"""' newline (multi-line-string-body newline)? (unicode-space | ws-escape)* '"""'

p_single_line_string_body :: Parser Text Source #

ref: (3.11) single-line-string-body := (string-character - newline)*

p_string_character :: Maybe (Parser invalid) -> Parser Text Source #

ref: (3.11) string-character := \\ (["\bfnrts] | 'u{' hex-unicode '}') | ws-escape | [^\"] - disallowed-literal-code-points

p_hex_unicode :: Parser Int Source #

ref: (3.11.1) hex-unicode := hex-digit{1, 6} - surrogate - above-max-scalar surrogate := [0]{0, 2} [dD] [8-9a-fA-F] hex-digit{2} // U+D800-DFFF: D 8 00 // D F FF above-max-scalar = [2-9a-fA-F] hex-digit{5} | [1] [1-9a-fA-F] hex-digit{4}

p_ws_escape :: Parser () Source #

ref: (3.11.1.1) ws-escape := \\ (unicode-space | newline)+

(3.12) Multi-line String

p_multi_line_string_body :: Parser end -> Parser MultilineChars Source #

ref: (3.12) multi-line-string-body := (('"' | '""')? string-character)*

Requires some changes to the grammar: https://github.com/kdl-org/kdl/pull/552

(3.13) Raw String

p_raw_string :: Parser Text Source #

ref: (3.13) raw-string := # raw-string-quotes # | # raw-string #

p_raw_string_quotes :: Parser end -> Parser Text Source #

ref: (3.13) raw-string-quotes := '"' single-line-raw-string-body '"' | '"""' newline (multi-line-raw-string-body newline)? unicode-space* '"""'

p_single_line_raw_string_body :: Parser end -> Parser () Source #

ref: (3.13) single-line-raw-string-body := '' | (single-line-raw-string-char - '"') single-line-raw-string-char*? | '"' (single-line-raw-string-char - '"') single-line-raw-string-char*?

p_single_line_raw_string_char :: Parser Char Source #

ref: (3.13) single-line-raw-string-char := unicode - newline - disallowed-literal-code-points

p_multi_line_raw_string_body :: Parser end -> Parser MultilineChars Source #

ref: (3.13) multi-line-raw-string-body := (unicode - disallowed-literal-code-points)*?

(3.14) Number

p_number :: Parser ValueData Source #

ref: (3.14) number := keyword-number | hex | octal | binary | decimal

p_hex :: Parser Scientific Source #

ref: (3.14) hex := sign? '0x' hex-digit (hex-digit | '_')*

p_hex_digit :: Parser Int Source #

ref: (3.14) hex-digit := [0-9a-fA-F]

p_octal :: Parser Scientific Source #

ref: (3.14) octal := sign? '0o' [0-7] [0-7_]*

p_binary :: Parser Scientific Source #

ref: (3.14) binary := sign? '0b' ('0' | '1') ('0' | '1' | '_')*

p_decimal :: Parser Scientific Source #

ref: (3.14) decimal := sign? integer (. integer)? exponent?

p_integer :: Parser (Integer, Int) Source #

ref: (3.14) integer := digit (digit | '_')*

p_exponent :: Parser Int Source #

ref: (3.14) exponent := (e | E) sign? integer

p_sign :: Parser Char Source #

ref: (3.14) sign := + | -

p_keyword_number :: Parser ValueData Source #

ref: (3.14.1) keyword-number := '#inf' | '#-inf' | '#nan'

(3.15) Boolean

p_boolean :: Parser Bool Source #

ref: (3.15) boolean := '#true' | '#false'

(3.17) Whitespace

p_ws :: Parser Text Source #

ref: (3.17) ws := unicode-space | multi-line-comment

p_unicode_space :: Parser Char Source #

ref: (3.17) unicode-space := See Table (All White_Space unicode characters which are not newline)

p_single_line_comment :: Parser Text Source #

ref: (3.17.1) single-line-comment := // ^newline* (newline | eof)

p_multi_line_comment :: Parser Text Source #

ref: (3.17.2) multi-line-comment := /* commented-block

p_slashdash :: Parser SlashdashResult Source #

ref: (3.17.3) slashdash := /- line-space*

(3.18) Newline

p_newline :: Parser Text Source #

ref: (3.18) newline := See Table (All Newline White_Space)

(3.19) Disallowed Literal Code Points

is_disallowed_literal_code_points :: Char -> Bool Source #

ref: (3.19) disallowed-literal-code-points := See Table (Disallowed Literal Code Points)

Unicode

p_unicode :: Parser Char Source #

unicode := Any Unicode Scalar Value