# Path: twyg/css3colors.py
# def _parse_hex(col):
# def _conv_rgb(c):
# def _conv_percent(p):
# def _conv_alpha(a):
# def _conv_hue(h):
# def color_to_rgba(col):
# def rgba_to_color(r, g, b, a, format='rgba'):
# 
# Path: twyg/tree.py
# class Direction(object):
#     Top, Right, Bottom, Left = range(4)


import math, os, re, sys
import operator as _operator
import twyg.common
from pkg_resources import resource_filename
    from collections import OrderedDict
    from twyg.ordereddict import OrderedDict
from twyg.css3colors import color_to_rgba, colornames
from twyg.tree import Direction


def include_path(configname):
    return find_config([configname], 'included config')


##############################################################################
# Pratt expression parser
##############################################################################

# Top-down operator-precedence parser based heavily on Fredrik Lundh's
# excellent article on Pratt parsers:
#
# http://effbot.org/zone/simple-top-down-parsing.htm
#
# Added type checking, function calls and extensive error reporting on
# my own.
#
# Further references:
#
# http://eli.thegreenplace.net/2010/01/02/top-down-operator-precedence-parsing/
# http://javascript.crockford.com/tdop/tdop.html

def parsecolor(mode, *components):
    """ Helper function to parse colors specified by their individual
    component values using the CSS3 color parser.
    """
    s = ', '.join([str(a) for a in components])
    if mode:
        s = mode + '(' + s + ')'

# Path: twyg/css3colors.py
# def _parse_hex(col):
# def _conv_rgb(c):
# def _conv_percent(p):
# def _conv_alpha(a):
# def _conv_hue(h):
# def color_to_rgba(col):
# def rgba_to_color(r, g, b, a, format='rgba'):
# 
# Path: twyg/tree.py
# class Direction(object):
#     Top, Right, Bottom, Left = range(4)


# Path: twyg/config.py
import math, os, re, sys
import operator as _operator
import twyg.common
from pkg_resources import resource_filename
    from collections import OrderedDict
    from twyg.ordereddict import OrderedDict
from twyg.css3colors import color_to_rgba, colornames
from twyg.tree import Direction



def include_path(configname):
    return find_config([configname], 'included config')


##############################################################################
# Pratt expression parser
##############################################################################

# Top-down operator-precedence parser based heavily on Fredrik Lundh's
# excellent article on Pratt parsers:
#
# http://effbot.org/zone/simple-top-down-parsing.htm
#
# Added type checking, function calls and extensive error reporting on
# my own.
#
# Further references:
#
# http://eli.thegreenplace.net/2010/01/02/top-down-operator-precedence-parsing/
# http://javascript.crockford.com/tdop/tdop.html

def parsecolor(mode, *components):
    """ Helper function to parse colors specified by their individual
    component values using the CSS3 color parser.
    """
    s = ', '.join([str(a) for a in components])
    if mode:
        s = mode + '(' + s + ')'

    return _ctx.color(*color_to_rgba(s))