# Path: tinycsscheme/tinycss/css21.py
# class Stylesheet(object):
# class AtRule(object):
# class RuleSet(object):
# class Declaration(object):
# class PageRule(object):
# class MediaRule(object):
# class ImportRule(object):
# class CSS21Parser(object):
#     def __init__(self, rules, errors, encoding):
#     def __repr__(self):
#     def __init__(self, at_keyword, head, body, line, column):
#     def __repr__(self):
#     def __init__(self, selector, declarations, line, column):
#     def __repr__(self):
#     def __init__(self, name, value, priority, line, column):
#     def __repr__(self):
#     def __init__(self, selector, specificity, declarations, at_rules,
#                  line, column):
#     def __repr__(self):
#     def __init__(self, media, rules, line, column):
#     def __repr__(self):
#     def __init__(self, uri, media, line, column):
#     def __repr__(self):
# def _remove_at_charset(tokens):
#     def parse_stylesheet_file(self, css_file, protocol_encoding=None,
#                              linking_encoding=None, document_encoding=None):
#     def parse_stylesheet_bytes(self, css_bytes, protocol_encoding=None,
#                                linking_encoding=None, document_encoding=None):
#     def parse_stylesheet(self, css_unicode, encoding=None):
#     def parse_style_attr(self, css_source):
#     def parse_rules(self, tokens, context):
#     def read_at_rule(self, at_keyword_token, tokens):
#     def parse_at_rule(self, rule, previous_rules, errors, context):
#     def parse_media(self, tokens):
#     def parse_page_selector(self, tokens):
#     def parse_declarations_and_at_rules(self, tokens, context):
#     def parse_ruleset(self, first_token, tokens):
#     def parse_declaration_list(self, tokens):
#     def parse_declaration(self, tokens):
#     def parse_value_priority(self, tokens):


from .css21 import CSS21Parser, ParseError
    |     @page table:right {} |     ('table', 'right') |
    +--------------------------+------------------------+

    """

    PAGE_MARGIN_AT_KEYWORDS = [
        '@top-left-corner',
        '@top-left',
        '@top-center',
        '@top-right',
        '@top-right-corner',
        '@bottom-left-corner',
        '@bottom-left',
        '@bottom-center',
        '@bottom-right',
        '@bottom-right-corner',
        '@left-top',
        '@left-middle',
        '@left-bottom',
        '@right-top',
        '@right-middle',
        '@right-bottom',
    ]

    def parse_at_rule(self, rule, previous_rules, errors, context):
        if rule.at_keyword in self.PAGE_MARGIN_AT_KEYWORDS:
            if context != '@page':
                raise ParseError(rule,
                    '%s rule not allowed in %s' % (rule.at_keyword, context))
            if rule.head:

# Path: tinycsscheme/tinycss/css21.py
# class Stylesheet(object):
# class AtRule(object):
# class RuleSet(object):
# class Declaration(object):
# class PageRule(object):
# class MediaRule(object):
# class ImportRule(object):
# class CSS21Parser(object):
#     def __init__(self, rules, errors, encoding):
#     def __repr__(self):
#     def __init__(self, at_keyword, head, body, line, column):
#     def __repr__(self):
#     def __init__(self, selector, declarations, line, column):
#     def __repr__(self):
#     def __init__(self, name, value, priority, line, column):
#     def __repr__(self):
#     def __init__(self, selector, specificity, declarations, at_rules,
#                  line, column):
#     def __repr__(self):
#     def __init__(self, media, rules, line, column):
#     def __repr__(self):
#     def __init__(self, uri, media, line, column):
#     def __repr__(self):
# def _remove_at_charset(tokens):
#     def parse_stylesheet_file(self, css_file, protocol_encoding=None,
#                              linking_encoding=None, document_encoding=None):
#     def parse_stylesheet_bytes(self, css_bytes, protocol_encoding=None,
#                                linking_encoding=None, document_encoding=None):
#     def parse_stylesheet(self, css_unicode, encoding=None):
#     def parse_style_attr(self, css_source):
#     def parse_rules(self, tokens, context):
#     def read_at_rule(self, at_keyword_token, tokens):
#     def parse_at_rule(self, rule, previous_rules, errors, context):
#     def parse_media(self, tokens):
#     def parse_page_selector(self, tokens):
#     def parse_declarations_and_at_rules(self, tokens, context):
#     def parse_ruleset(self, first_token, tokens):
#     def parse_declaration_list(self, tokens):
#     def parse_declaration(self, tokens):
#     def parse_value_priority(self, tokens):


# Path: tinycsscheme/tinycss/page3.py
from .css21 import CSS21Parser, ParseError

    |     @page table:right {} |     ('table', 'right') |
    +--------------------------+------------------------+

    """

    PAGE_MARGIN_AT_KEYWORDS = [
        '@top-left-corner',
        '@top-left',
        '@top-center',
        '@top-right',
        '@top-right-corner',
        '@bottom-left-corner',
        '@bottom-left',
        '@bottom-center',
        '@bottom-right',
        '@bottom-right-corner',
        '@left-top',
        '@left-middle',
        '@left-bottom',
        '@right-top',
        '@right-middle',
        '@right-bottom',
    ]

    def parse_at_rule(self, rule, previous_rules, errors, context):
        if rule.at_keyword in self.PAGE_MARGIN_AT_KEYWORDS:
            if context != '@page':
                raise ParseError(rule,
                    '%s rule not allowed in %s' % (rule.at_keyword, context))
            if rule.head:

                raise ParseError(rule.head[0],