Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Classes | Functions | Variables
myst_parser.parsers.options Namespace Reference

Classes

class  ColonToken
 
class  KeyToken
 
class  Position
 
class  State
 
class  StreamBuffer
 
class  Token
 
class  TokenizeError
 
class  ValueToken
 

Functions

tuple[list[tuple[str, str]], Stateoptions_to_items (str text, int line_offset=0, int column_offset=0)
 
Iterable[tuple[KeyToken, ValueToken|None]] _to_tokens (str text, State state, int line_offset=0, int column_offset=0)
 
Iterable[Token_tokenize (str text, State state)
 
None _scan_to_next_token (StreamBuffer stream, State state)
 
KeyToken|ValueToken _scan_plain_scalar (StreamBuffer stream, State state, bool is_key=False)
 
list[str] _scan_plain_spaces (StreamBuffer stream, bool allow_newline=True)
 
str _scan_line_break (StreamBuffer stream)
 
KeyToken|ValueToken _scan_flow_scalar (StreamBuffer stream, Literal["'", '"'] style, bool is_key=False)
 
list[str] _scan_flow_scalar_non_spaces (StreamBuffer stream, bool double, Position start_mark)
 
list[str] _scan_flow_scalar_spaces (StreamBuffer stream, Position start_mark)
 
list[str] _scan_flow_scalar_breaks (StreamBuffer stream)
 
ValueToken _scan_block_scalar (StreamBuffer stream, Literal["|", ">"] style, State state)
 
tuple[bool|None, int|None] _scan_block_scalar_indicators (StreamBuffer stream, Position start_mark)
 
None _scan_block_scalar_ignored_line (StreamBuffer stream, Position start_mark, State state)
 
tuple[list[str], int, Position_scan_block_scalar_indentation (StreamBuffer stream)
 
tuple[list[str], Position_scan_block_scalar_breaks (StreamBuffer stream, int indent)
 

Variables

Final _CHARS_END = "\0"
 
Final _CHARS_NEWLINE = "\r\n\x85\u2028\u2029"
 
Final _CHARS_END_NEWLINE = "\0\r\n\x85\u2028\u2029"
 
Final _CHARS_SPACE_NEWLINE = " \r\n\x85\u2028\u2029"
 
Final _CHARS_END_SPACE_NEWLINE = "\0 \r\n\x85\u2028\u2029"
 
Final _CHARS_END_SPACE_TAB_NEWLINE = "\0 \t\r\n\x85\u2028\u2029"
 
dict _ESCAPE_REPLACEMENTS
 
dict _ESCAPE_CODES
 

Detailed Description

Parser for directive options.

This is a highly restricted parser for YAML,
which only allows a subset of YAML to be used for directive options:

- Only block mappings are allowed at the top level
- Mapping keys are parsed as strings (plain or quoted)
- Mapping values are parsed as strings (plain, quoted, literal `|`, folded `>`)
- `#` Comments are allowed and blank lines

Adapted from:
https://github.com/yaml/pyyaml/commit/957ae4d495cf8fcb5475c6c2f1bce801096b68a5

For a good description of multi-line YAML strings, see:
https://stackoverflow.com/a/21699210/5033292

Function Documentation

◆ _scan_to_next_token()

None myst_parser.parsers.options._scan_to_next_token ( StreamBuffer  stream,
State  state 
)
protected
Skip spaces, line breaks and comments.

The byte order mark is also stripped,
if it's the first character in the stream.

◆ _to_tokens()

Iterable[tuple[KeyToken, ValueToken | None]] myst_parser.parsers.options._to_tokens ( str  text,
State  state,
int   line_offset = 0,
int   column_offset = 0 
)
protected
Parse a directive option, and yield key/value token pairs.

:param text: The directive option text.
:param line_offset: The line offset to apply to the error positions.
:param column_offset: The column offset to apply to the error positions.

:raises: `TokenizeError`

◆ _tokenize()

Iterable[Token] myst_parser.parsers.options._tokenize ( str  text,
State  state 
)
protected
Yield tokens from a directive option stream.

◆ options_to_items()

tuple[list[tuple[str, str]], State] myst_parser.parsers.options.options_to_items ( str  text,
int   line_offset = 0,
int   column_offset = 0 
)
Parse a directive option block into (key, value) tuples.

:param text: The directive option text.
:param line_offset: The line offset to apply to the error positions.
:param column_offset: The column offset to apply to the error positions.

:raises: `TokenizeError`

Variable Documentation

◆ _ESCAPE_CODES

dict myst_parser.parsers.options._ESCAPE_CODES
protected
Initial value:
1= {
2 "x": 2,
3 "u": 4,
4 "U": 8,
5}

◆ _ESCAPE_REPLACEMENTS

dict myst_parser.parsers.options._ESCAPE_REPLACEMENTS
protected
Initial value:
1= {
2 "0": "\0",
3 "a": "\x07",
4 "b": "\x08",
5 "t": "\x09",
6 "\t": "\x09",
7 "n": "\x0a",
8 "v": "\x0b",
9 "f": "\x0c",
10 "r": "\x0d",
11 "e": "\x1b",
12 " ": "\x20",
13 '"': '"',
14 "\\": "\\",
15 "/": "/",
16 "N": "\x85",
17 "_": "\xa0",
18 "L": "\u2028",
19 "P": "\u2029",
20}