# Copyright (c) 2017-2026 Juancarlo Añez (apalala@gmail.com)
# SPDX-License-Identifier: BSD-4-Clause
from __future__ import annotations

from typing import Any

from .objectmodel.builder import ModelBuilderSemantics
from .util import simplify_list
from .util.typetools import TypeContainer


__all__ = ['ASTSemantics', 'ModelBuilderSemantics', 'TypeContainer']


class ASTSemantics:
    def group(self, ast: Any, *args) -> Any:
        _ = args
        return simplify_list(ast)

    def element(self, ast: Any, *args) -> Any:
        _ = args
        return simplify_list(ast)

    def sequence(self, ast: Any, *args) -> Any:
        _ = args
        return simplify_list(ast)

    def choice(self, ast: Any, *args) -> Any:
        _ = args
        if len(ast) == 1:
            return simplify_list(ast[0])
        return ast
