Module scrolls.ast.ast_constants

Numeric and string constants for the language.

Expand source code
"""
Numeric and string constants for the language.
"""

import enum
import typing as t

__all__ = (
    "EOF",
    "COMMAND_SEP",
    "BLOCK_OPEN",
    "BLOCK_CLOSE",
    "OPEN_ARGS",
    "CLOSE_ARGS",
    "CONTROL_SIGIL",
    "EXPANSION_SIGIL",
    "SPREAD_SIGIL",
    "COMMENT_SIGIL",
    "QUOTE",
    "ESCAPE_SIGIL",
    "TokenType",
    "TokenizeConsumeRestState",
    "ASTNodeType"
)


EOF: str = ""
"""End-of-file indicator."""

COMMAND_SEP: t.Sequence[str] = [";", "\n"]
"""Command separator characters."""

BLOCK_OPEN: str = "{"
"""Open character for a code block."""

BLOCK_CLOSE: str = "}"
"""Close character for a code block."""

OPEN_ARGS: str = "("
"""Open character for a set of arguments."""

CLOSE_ARGS: str = ")"
"""Close character for a set of arguments."""

CONTROL_SIGIL = "!"
"""Character introducing a control call."""

EXPANSION_SIGIL = "$"
"""Character introducing variable and call expansion."""

SPREAD_SIGIL = "^"
"""Character indicating spread expansion."""

COMMENT_SIGIL = "#"
"""Character introducing a comment."""

QUOTE = "\""
"""Character for quoting strings."""

ESCAPE_SIGIL = "\\"
"""Character than introduces escape sequences in quoted literals."""


class TokenType(enum.Enum):
    """
    All possible token types generated by `scrolls.ast.tokenizer.Tokenizer`.
    """

    OPEN_ARGS = 1
    CLOSE_ARGS = 2
    OPEN_BLOCK = 3
    CLOSE_BLOCK = 4
    EXPANSION_SIGIL = 5
    SPREAD_SIGIL = 6
    CONTROL_SIGIL = 7
    COMMAND_SEP = 8
    STRING_LITERAL = 9
    EOF = 10
    WHITESPACE = 11
    COMMENT = 12


class TokenizeConsumeRestState(enum.Enum):
    """
    Internal `scrolls.ast.tokenizer.Tokenizer` state for the CONSUME_REST feature.
    """

    OFF = 0
    COUNTING = 1
    CONSUME = 2


class ASTNodeType(enum.Enum):
    """
    All possible AST node types.
    """

    NONE = 0
    """AST nodes with this type should be ignored."""

    EOF = 1
    """A node representing EOF."""

    ROOT = 2
    """The root AST node."""

    STRING = 3
    """A string literal."""

    COMMAND_CALL = 4
    """The parent node for a command call."""

    COMMAND_ARGUMENTS = 5
    """The parent node for a list of command arguments."""

    BLOCK = 6
    """A block of statements."""

    CONTROL_CALL = 7
    """The parent node for a control call."""

    CONTROL_ARGUMENTS = 8
    """The parent node for a list of control arguments."""

    EXPANSION = 9
    """The parent node for an expansion, either variable or call."""

    EXPANSION_SINGLE = 10
    """Indicates an expansion should use normal expansion."""

    EXPANSION_SPREAD = 11
    """Indicates an expansion should use vector expansion."""

    EXPANSION_VAR = 12
    """Parent node for a variable expansion."""

    EXPANSION_CALL = 13
    """Parent node for an expansion call."""

    EXPANSION_ARGUMENTS = 14
    """Parent node for a list of expansion arguments. Applies only to calls."""

Global variables

var BLOCK_CLOSE : str

Close character for a code block.

var BLOCK_OPEN : str

Open character for a code block.

var CLOSE_ARGS : str

Close character for a set of arguments.

var COMMAND_SEP : Sequence[str]

Command separator characters.

var COMMENT_SIGIL

Character introducing a comment.

var CONTROL_SIGIL

Character introducing a control call.

var EOF : str

End-of-file indicator.

var ESCAPE_SIGIL

Character than introduces escape sequences in quoted literals.

var EXPANSION_SIGIL

Character introducing variable and call expansion.

var OPEN_ARGS : str

Open character for a set of arguments.

var QUOTE

Character for quoting strings.

var SPREAD_SIGIL

Character indicating spread expansion.

Classes

class ASTNodeType (value, names=None, *, module=None, qualname=None, type=None, start=1)

All possible AST node types.

Expand source code
class ASTNodeType(enum.Enum):
    """
    All possible AST node types.
    """

    NONE = 0
    """AST nodes with this type should be ignored."""

    EOF = 1
    """A node representing EOF."""

    ROOT = 2
    """The root AST node."""

    STRING = 3
    """A string literal."""

    COMMAND_CALL = 4
    """The parent node for a command call."""

    COMMAND_ARGUMENTS = 5
    """The parent node for a list of command arguments."""

    BLOCK = 6
    """A block of statements."""

    CONTROL_CALL = 7
    """The parent node for a control call."""

    CONTROL_ARGUMENTS = 8
    """The parent node for a list of control arguments."""

    EXPANSION = 9
    """The parent node for an expansion, either variable or call."""

    EXPANSION_SINGLE = 10
    """Indicates an expansion should use normal expansion."""

    EXPANSION_SPREAD = 11
    """Indicates an expansion should use vector expansion."""

    EXPANSION_VAR = 12
    """Parent node for a variable expansion."""

    EXPANSION_CALL = 13
    """Parent node for an expansion call."""

    EXPANSION_ARGUMENTS = 14
    """Parent node for a list of expansion arguments. Applies only to calls."""

Ancestors

  • enum.Enum

Class variables

var BLOCK

A block of statements.

var COMMAND_ARGUMENTS

The parent node for a list of command arguments.

var COMMAND_CALL

The parent node for a command call.

var CONTROL_ARGUMENTS

The parent node for a list of control arguments.

var CONTROL_CALL

The parent node for a control call.

var EOF

A node representing EOF.

var EXPANSION

The parent node for an expansion, either variable or call.

var EXPANSION_ARGUMENTS

Parent node for a list of expansion arguments. Applies only to calls.

var EXPANSION_CALL

Parent node for an expansion call.

var EXPANSION_SINGLE

Indicates an expansion should use normal expansion.

var EXPANSION_SPREAD

Indicates an expansion should use vector expansion.

var EXPANSION_VAR

Parent node for a variable expansion.

var NONE

AST nodes with this type should be ignored.

var ROOT

The root AST node.

var STRING

A string literal.

class TokenType (value, names=None, *, module=None, qualname=None, type=None, start=1)

All possible token types generated by Tokenizer.

Expand source code
class TokenType(enum.Enum):
    """
    All possible token types generated by `scrolls.ast.tokenizer.Tokenizer`.
    """

    OPEN_ARGS = 1
    CLOSE_ARGS = 2
    OPEN_BLOCK = 3
    CLOSE_BLOCK = 4
    EXPANSION_SIGIL = 5
    SPREAD_SIGIL = 6
    CONTROL_SIGIL = 7
    COMMAND_SEP = 8
    STRING_LITERAL = 9
    EOF = 10
    WHITESPACE = 11
    COMMENT = 12

Ancestors

  • enum.Enum

Class variables

var CLOSE_ARGS
var CLOSE_BLOCK
var COMMAND_SEP
var COMMENT
var CONTROL_SIGIL
var EOF
var EXPANSION_SIGIL
var OPEN_ARGS
var OPEN_BLOCK
var SPREAD_SIGIL
var STRING_LITERAL
var WHITESPACE
class TokenizeConsumeRestState (value, names=None, *, module=None, qualname=None, type=None, start=1)

Internal Tokenizer state for the CONSUME_REST feature.

Expand source code
class TokenizeConsumeRestState(enum.Enum):
    """
    Internal `scrolls.ast.tokenizer.Tokenizer` state for the CONSUME_REST feature.
    """

    OFF = 0
    COUNTING = 1
    CONSUME = 2

Ancestors

  • enum.Enum

Class variables

var CONSUME
var COUNTING
var OFF