onlinejudge_template.analyzer.match module

the module to match format trees and sample strings

この module はフォーマット木とサンプル文字列がマッチするか判定し、マッチするならその結果を求めます。 たとえば

sequence([
    item("N"),
    newline(),
    loop(counter="i", size="N",
        item("A", indices="i")
    ),
    newline(),
])

のようなフォーマット木 (FormatNode) と

6
1 3 8 7 10 2

というサンプル文字列が与えられれば

{
    "N": 6,
    "A": [1, 3, 8, 7, 10, 2],
}

に相当する結果を返します。

exception onlinejudge_template.analyzer.match.FormatMatchError[source]

Bases: onlinejudge_template.types.AnalyzerError

onlinejudge_template.analyzer.match.match_format(node: onlinejudge_template.types.FormatNode, data: str, *, variables: Dict[NewType.<locals>.new_type, onlinejudge_template.types.VarDecl], values: Optional[Dict[NewType.<locals>.new_type, Dict[Tuple[int, ...], Union[int, float, str]]]] = None) → Dict[NewType.<locals>.new_type, Dict[Tuple[int, ...], Union[int, float, str]]][source]
Raises:FormatMatchError
Parameters:values – is an optional argument to specify pre-defined variables.