# Path: penman/types.py

# 
# Path: penman/exceptions.py
# class ConstantError(PenmanError):
#     """Raised when working with invalid constant values."""


from typing import Union
from enum import Enum
from penman.types import Constant
from penman.exceptions import ConstantError
import json
        >>> constant.evaluate('-')
        '-'
        >>> constant.evaluate('"foo"')
        'foo'
        >>> constant.evaluate('1')
        1
        >>> constant.evaluate('1.2')
        1.2
        >>> constant.evaluate('') is None
        True
    """
    value: Constant = constant_string
    if value is None or value == '':
        value = None
    else:
        assert isinstance(constant_string, str)
        if constant_string.startswith('"') ^ constant_string.endswith('"'):
            raise ConstantError(f'unbalanced quotes: {constant_string}')
        if constant_string not in ('true', 'false', 'null'):
            try:
                value = json.loads(constant_string, parse_constant=str)
            except json.JSONDecodeError:
                value = constant_string

    if not (value is None or isinstance(value, (str, int, float))):
        raise ConstantError(f'invalid constant: {value!r}')

    return value



# Path: penman/types.py

# 
# Path: penman/exceptions.py
# class ConstantError(PenmanError):
#     """Raised when working with invalid constant values."""


# Path: penman/constant.py
from typing import Union
from enum import Enum
from penman.types import Constant
from penman.exceptions import ConstantError
import json

        >>> constant.evaluate('-')
        '-'
        >>> constant.evaluate('"foo"')
        'foo'
        >>> constant.evaluate('1')
        1
        >>> constant.evaluate('1.2')
        1.2
        >>> constant.evaluate('') is None
        True
    """
    value: Constant = constant_string
    if value is None or value == '':
        value = None
    else:
        assert isinstance(constant_string, str)
        if constant_string.startswith('"') ^ constant_string.endswith('"'):
            raise ConstantError(f'unbalanced quotes: {constant_string}')
        if constant_string not in ('true', 'false', 'null'):
            try:
                value = json.loads(constant_string, parse_constant=str)
            except json.JSONDecodeError:
                value = constant_string

    if not (value is None or isinstance(value, (str, int, float))):
        raise ConstantError(f'invalid constant: {value!r}')

    return value



def quote(constant: Constant) -> str: