# Path: css2video/parsers/base.py
# class BaseParser(object):
#     """
#     A base class for all the parsers
# 
#     Attributes
#     ----------
#     ParseException : object
#         exception to be raised when there is a parsing error
# 
#     Methods
#     -------
#     grammar :
#         method to be overrridden by inheriting class which defines the grammar
#     parse_action :
#         method to be overrridden by inheriting class which defines the parse
#         action for the matched token
#     parser :
#         returns a parser by setting the parse action to the grammar
#     parse :
#         method to parse a string into a dictionary using the grammar and parse
#         action
#     """
# 
#     ParseException = None
# 
#     @classmethod
#     def grammar(cls):
#         """This method is overridden by the class which inherits the
#         BaseParser. The method should return a grammar"""
#         raise NotImplemented()
# 
#     @classmethod
#     def parse_action(cls):
#         """This method is overridden by the class which inherits the
#         BaseParser. The method should create a dictionary from the parsed
#         tokens"""
#         raise NotImplemented()
# 
#     @classmethod
#     def parser(cls):
#         """Returns the grammar with parse action set so that once the result is
#         parsed, the output is available as a dictionary"""
#         return cls.grammar().setParseAction(cls.parse_action)
# 
#     @classmethod
#     def parse(cls, string):
#         """
#         Parse a given string using the grammar and parse action and returns
#         a dictionary
# 
#         Parameters
#         ----------
#         string : str
#             string to be parsed
# 
#         Returns
#         -------
#         dict :
#             dictionary after parsing the string
#         """
#         try:
#             return cls.parser().parseString(string, parseAll=True)[0]
#         except pp.ParseException:
#             raise cls.ParseException()
# 
# Path: css2video/parsers/property.py
# class Property(BaseParser):
#     """Parse a CSS property"""
# 
#     ParseException = PropertyParseException
# 
#     @classmethod
#     def grammar(cls):
#         """Grammar to parse a CSS property"""
#         name = pp.Word(pp.alphas + '-')
#         value = Value.parser()
#         return (
#             name +
#             pp.Suppress(pp.Literal(':')) +
#             value +
#             pp.Suppress(pp.Literal(";"))
#         )
# 
#     @classmethod
#     def parse_action(cls, tokens):
#         """Returns a dictionary from the parsed tokens"""
#         return {
#             'property_name': tokens[0].lower(),  # Normalize the name
#             'property_value': tokens[1]
#         }
# 
# Path: css2video/constants.py
# class RuleType(object):
#     """Class to define constants for rule types"""
# 
#     style = 'style'
#     keyframes = 'keyframes'


import pyparsing as pp
from .base import BaseParser
from .property import Property
from css2video.constants import RuleType
        }


class KeyframePropertiesParseException(Exception):
    """Raised when there is an exception while parsing the keyframe
    properties"""
    pass


class KeyframeProperties(BaseParser):
    """Parse keyframe properties"""

    ParseException = KeyframePropertiesParseException

    @classmethod
    def grammar(cls):
        """Grammar to parse keyframe properties"""
        # Todo: Handle keyframe properties where there are more than one
        # keyframe selectors
        keyframe_selector = (
            (
                pp.Word(pp.nums + '.') +
                pp.Suppress(pp.Literal('%')).leaveWhitespace()
            ) |
            pp.Literal('from') |
            pp.Literal('to')
        )
        return (
            keyframe_selector +
            pp.Suppress(pp.Literal('{')) +

# Path: css2video/parsers/base.py
# class BaseParser(object):
#     """
#     A base class for all the parsers
# 
#     Attributes
#     ----------
#     ParseException : object
#         exception to be raised when there is a parsing error
# 
#     Methods
#     -------
#     grammar :
#         method to be overrridden by inheriting class which defines the grammar
#     parse_action :
#         method to be overrridden by inheriting class which defines the parse
#         action for the matched token
#     parser :
#         returns a parser by setting the parse action to the grammar
#     parse :
#         method to parse a string into a dictionary using the grammar and parse
#         action
#     """
# 
#     ParseException = None
# 
#     @classmethod
#     def grammar(cls):
#         """This method is overridden by the class which inherits the
#         BaseParser. The method should return a grammar"""
#         raise NotImplemented()
# 
#     @classmethod
#     def parse_action(cls):
#         """This method is overridden by the class which inherits the
#         BaseParser. The method should create a dictionary from the parsed
#         tokens"""
#         raise NotImplemented()
# 
#     @classmethod
#     def parser(cls):
#         """Returns the grammar with parse action set so that once the result is
#         parsed, the output is available as a dictionary"""
#         return cls.grammar().setParseAction(cls.parse_action)
# 
#     @classmethod
#     def parse(cls, string):
#         """
#         Parse a given string using the grammar and parse action and returns
#         a dictionary
# 
#         Parameters
#         ----------
#         string : str
#             string to be parsed
# 
#         Returns
#         -------
#         dict :
#             dictionary after parsing the string
#         """
#         try:
#             return cls.parser().parseString(string, parseAll=True)[0]
#         except pp.ParseException:
#             raise cls.ParseException()
# 
# Path: css2video/parsers/property.py
# class Property(BaseParser):
#     """Parse a CSS property"""
# 
#     ParseException = PropertyParseException
# 
#     @classmethod
#     def grammar(cls):
#         """Grammar to parse a CSS property"""
#         name = pp.Word(pp.alphas + '-')
#         value = Value.parser()
#         return (
#             name +
#             pp.Suppress(pp.Literal(':')) +
#             value +
#             pp.Suppress(pp.Literal(";"))
#         )
# 
#     @classmethod
#     def parse_action(cls, tokens):
#         """Returns a dictionary from the parsed tokens"""
#         return {
#             'property_name': tokens[0].lower(),  # Normalize the name
#             'property_value': tokens[1]
#         }
# 
# Path: css2video/constants.py
# class RuleType(object):
#     """Class to define constants for rule types"""
# 
#     style = 'style'
#     keyframes = 'keyframes'


# Path: css2video/parsers/rule.py
import pyparsing as pp
from .base import BaseParser
from .property import Property
from css2video.constants import RuleType

        }


class KeyframePropertiesParseException(Exception):
    """Raised when there is an exception while parsing the keyframe
    properties"""
    pass


class KeyframeProperties(BaseParser):
    """Parse keyframe properties"""

    ParseException = KeyframePropertiesParseException

    @classmethod
    def grammar(cls):
        """Grammar to parse keyframe properties"""
        # Todo: Handle keyframe properties where there are more than one
        # keyframe selectors
        keyframe_selector = (
            (
                pp.Word(pp.nums + '.') +
                pp.Suppress(pp.Literal('%')).leaveWhitespace()
            ) |
            pp.Literal('from') |
            pp.Literal('to')
        )
        return (
            keyframe_selector +
            pp.Suppress(pp.Literal('{')) +

            pp.ZeroOrMore(Property.parser()) +