grammar CssColor;

import BaseNumbers;

color
    : colorHSL      #color_hsl
    | colorHSLA     #color_hsla
    | colorRGB      #color_rgb
    | colorRGBA     #color_rgba
    | colorHEX      #color_hex
    ;

colorHSL
    : PREFIX_HSL LP h=componentHue CS s=componentSaturation CS l=componentLightness RP
    ;

colorHSLA
    : (PREFIX_HSL|PREFIX_HSLA) LP h=componentHue CS s=componentSaturation CS l=componentLightness CS alpha=componentAlpha RP
    ;

colorRGB
    : (PREFIX_RGB|PREFIX_RGBA) LP r=componentRGB CS g=componentRGB CS b=componentRGB RP
    ;

colorRGBA
    : PREFIX_RGBA LP r=componentRGB CS g=componentRGB CS b=componentRGB CS alpha=componentAlpha RP
    ;

colorHEX
    : codeHex
    ;

componentHue
    : numberInt
    ;

componentSaturation
    : numberPct
    ;

componentLightness
    : numberPct
    ;

componentRGB
    : numberInt
    ;

componentAlpha
    : numberReal
    | numberInt
    ;

PREFIX_RGB   : 'rgb'  CHAR_WS*;
PREFIX_RGBA  : 'rgba' CHAR_WS*;
PREFIX_HSL   : 'hsl'  CHAR_WS*;
PREFIX_HSLA  : 'hsla' CHAR_WS*;
