Пример #1
0
 def interpolated_string(self):
     _token_ = self._peek(self.interpolated_string_rsts)
     if _token_ == 'SINGLE_QUOTE':
         interpolated_string_single = self.interpolated_string_single()
         return Interpolation.maybe(interpolated_string_single, quotes="'")
     else:  # == 'DOUBLE_QUOTE'
         interpolated_string_double = self.interpolated_string_double()
         return Interpolation.maybe(interpolated_string_double, quotes='"')
Пример #2
0
 def interpolated_string(self):
     _token_ = self._peek(self.interpolated_string_rsts)
     if _token_ == 'SINGLE_QUOTE':
         interpolated_string_single = self.interpolated_string_single()
         return Interpolation.maybe(interpolated_string_single, quotes="'")
     else:  # == 'DOUBLE_QUOTE'
         interpolated_string_double = self.interpolated_string_double()
         return Interpolation.maybe(interpolated_string_double, quotes='"')
Пример #3
0
 def interpolated_url(self):
     _token_ = self._peek(self.interpolated_url_rsts)
     if _token_ == 'BAREURL':
         interpolated_bare_url = self.interpolated_bare_url()
         return Interpolation.maybe(interpolated_bare_url, type=Url, quotes=None)
     elif _token_ == 'SINGLE_QUOTE':
         interpolated_string_single = self.interpolated_string_single()
         return Interpolation.maybe(interpolated_string_single, type=Url, quotes="'")
     else:  # == 'DOUBLE_QUOTE'
         interpolated_string_double = self.interpolated_string_double()
         return Interpolation.maybe(interpolated_string_double, type=Url, quotes='"')
Пример #4
0
 def interpolated_url(self):
     _token_ = self._peek(self.interpolated_url_rsts)
     if _token_ in self.interpolated_url_chks:
         interpolated_bare_url = self.interpolated_bare_url()
         return Interpolation.maybe(interpolated_bare_url, type=Url, quotes=None)
     else:  # in self.argspec_item_chks
         expr_lst = self.expr_lst()
         return FunctionLiteral(expr_lst, "url")
Пример #5
0
 def goal_interpolated_literal(self):
     INTERP_ANYTHING = self._scan('INTERP_ANYTHING')
     parts = [INTERP_ANYTHING]
     while self._peek(self.goal_interpolated_literal_rsts) == 'INTERP_START':
         interpolation = self.interpolation()
         parts.append(interpolation)
         INTERP_ANYTHING = self._scan('INTERP_ANYTHING')
         parts.append(INTERP_ANYTHING)
     END = self._scan('END')
     return Interpolation.maybe(parts)
Пример #6
0
 def interpolated_url(self):
     _token_ = self._peek(self.interpolated_url_rsts)
     if _token_ in self.interpolated_url_chks:
         interpolated_bare_url = self.interpolated_bare_url()
         return Interpolation.maybe(interpolated_bare_url,
                                    type=Url,
                                    quotes=None)
     else:  # in self.argspec_item_chks
         expr_lst = self.expr_lst()
         return FunctionLiteral(expr_lst, "url")
Пример #7
0
 def goal_interpolated_anything(self):
     INTERP_ANYTHING = self._scan("INTERP_ANYTHING")
     parts = [INTERP_ANYTHING]
     while self._peek(self.goal_interpolated_anything_rsts) == "INTERP_START":
         interpolation = self.interpolation()
         parts.append(interpolation)
         INTERP_ANYTHING = self._scan("INTERP_ANYTHING")
         parts.append(INTERP_ANYTHING)
     END = self._scan("END")
     return Interpolation.maybe(parts)
Пример #8
0
 def goal_interpolated_anything(self):
     INTERP_ANYTHING = self._scan('INTERP_ANYTHING')
     parts = [INTERP_ANYTHING]
     while self._peek(
             self.goal_interpolated_anything_rsts) == 'INTERP_START':
         interpolation = self.interpolation()
         parts.append(interpolation)
         INTERP_ANYTHING = self._scan('INTERP_ANYTHING')
         parts.append(INTERP_ANYTHING)
     END = self._scan('END')
     return Interpolation.maybe(parts)
Пример #9
0
 def goal_interpolated_literal_with_vars(self):
     INTERP_NO_VARS = self._scan('INTERP_NO_VARS')
     parts = [INTERP_NO_VARS]
     while self._peek(self.goal_interpolated_literal_with_vars_rsts) != 'END':
         _token_ = self._peek(self.goal_interpolated_literal_with_vars_rsts_)
         if _token_ == 'INTERP_START':
             interpolation = self.interpolation()
             parts.append(interpolation)
         else:  # == 'VAR'
             VAR = self._scan('VAR')
             parts.append(Variable(VAR))
         INTERP_NO_VARS = self._scan('INTERP_NO_VARS')
         parts.append(INTERP_NO_VARS)
     END = self._scan('END')
     return Interpolation.maybe(parts)
Пример #10
0
 def goal_interpolated_literal_with_vars(self):
     INTERP_NO_VARS = self._scan('INTERP_NO_VARS')
     parts = [INTERP_NO_VARS]
     while self._peek(
             self.goal_interpolated_literal_with_vars_rsts) != 'END':
         _token_ = self._peek(
             self.goal_interpolated_literal_with_vars_rsts_)
         if _token_ == 'INTERP_START':
             interpolation = self.interpolation()
             parts.append(interpolation)
         else:  # == 'VAR'
             VAR = self._scan('VAR')
             parts.append(Variable(VAR))
         INTERP_NO_VARS = self._scan('INTERP_NO_VARS')
         parts.append(INTERP_NO_VARS)
     END = self._scan('END')
     return Interpolation.maybe(parts)
Пример #11
0
 def atom(self):
     _token_ = self._peek(self.u_expr_chks)
     if _token_ == 'LPAR':
         LPAR = self._scan('LPAR')
         _token_ = self._peek(self.atom_rsts)
         if _token_ == 'RPAR':
             v = ListLiteral([], comma=False)
         else:  # in self.argspec_item_chks
             expr_map_or_list = self.expr_map_or_list()
             v = expr_map_or_list
         RPAR = self._scan('RPAR')
         return Parentheses(v)
     elif _token_ == 'URL_FUNCTION':
         URL_FUNCTION = self._scan('URL_FUNCTION')
         LPAR = self._scan('LPAR')
         interpolated_url = self.interpolated_url()
         RPAR = self._scan('RPAR')
         return interpolated_url
     elif _token_ == 'ALPHA_FUNCTION':
         ALPHA_FUNCTION = self._scan('ALPHA_FUNCTION')
         LPAR = self._scan('LPAR')
         _token_ = self._peek(self.atom_rsts_)
         if _token_ == 'OPACITY':
             OPACITY = self._scan('OPACITY')
             self._scan('"="')
             atom = self.atom()
             RPAR = self._scan('RPAR')
             return AlphaFunctionLiteral(atom)
         else:  # in self.atom_chks
             argspec = self.argspec()
             RPAR = self._scan('RPAR')
             return CallOp("alpha", argspec)
     elif _token_ == 'IF_FUNCTION':
         IF_FUNCTION = self._scan('IF_FUNCTION')
         LPAR = self._scan('LPAR')
         expr_lst = self.expr_lst()
         RPAR = self._scan('RPAR')
         return TernaryOp(expr_lst)
     elif _token_ == 'LITERAL_FUNCTION':
         LITERAL_FUNCTION = self._scan('LITERAL_FUNCTION')
         LPAR = self._scan('LPAR')
         interpolated_function = self.interpolated_function()
         RPAR = self._scan('RPAR')
         return Interpolation.maybe(interpolated_function, type=Function, function_name=LITERAL_FUNCTION)
     elif _token_ == 'FNCT':
         FNCT = self._scan('FNCT')
         LPAR = self._scan('LPAR')
         argspec = self.argspec()
         RPAR = self._scan('RPAR')
         return CallOp(FNCT, argspec)
     elif _token_ == 'BANG_IMPORTANT':
         BANG_IMPORTANT = self._scan('BANG_IMPORTANT')
         return Literal(String.unquoted("!important", literal=True))
     elif _token_ in self.atom_chks_:
         interpolated_bareword = self.interpolated_bareword()
         return Interpolation.maybe(interpolated_bareword)
     elif _token_ == 'NUM':
         NUM = self._scan('NUM')
         UNITS = None
         if self._peek(self.atom_rsts__) == 'UNITS':
             UNITS = self._scan('UNITS')
         return Literal(Number(float(NUM), unit=UNITS))
     elif _token_ not in self.atom_chks__:
         interpolated_string = self.interpolated_string()
         return interpolated_string
     elif _token_ == 'COLOR':
         COLOR = self._scan('COLOR')
         return Literal(Color.from_hex(COLOR, literal=True))
     else:  # == 'VAR'
         VAR = self._scan('VAR')
         return Variable(VAR)
Пример #12
0
 def atom(self):
     _token_ = self._peek(self.u_expr_chks)
     if _token_ == 'LPAR':
         LPAR = self._scan('LPAR')
         _token_ = self._peek(self.atom_rsts)
         if _token_ == 'RPAR':
             v = ListLiteral([], comma=False)
         else:  # in self.argspec_item_chks
             expr_map_or_list = self.expr_map_or_list()
             v = expr_map_or_list
         RPAR = self._scan('RPAR')
         return Parentheses(v)
     elif _token_ == 'URL_FUNCTION':
         URL_FUNCTION = self._scan('URL_FUNCTION')
         LPAR = self._scan('LPAR')
         interpolated_url = self.interpolated_url()
         RPAR = self._scan('RPAR')
         return interpolated_url
     elif _token_ == 'ALPHA_FUNCTION':
         ALPHA_FUNCTION = self._scan('ALPHA_FUNCTION')
         LPAR = self._scan('LPAR')
         _token_ = self._peek(self.atom_rsts_)
         if _token_ == '"opacity"':
             self._scan('"opacity"')
             self._scan('"="')
             atom = self.atom()
             RPAR = self._scan('RPAR')
             return AlphaFunctionLiteral(atom)
         else:  # in self.atom_chks
             argspec = self.argspec()
             RPAR = self._scan('RPAR')
             return CallOp("alpha", argspec)
     elif _token_ == 'LITERAL_FUNCTION':
         LITERAL_FUNCTION = self._scan('LITERAL_FUNCTION')
         LPAR = self._scan('LPAR')
         interpolated_function = self.interpolated_function()
         RPAR = self._scan('RPAR')
         return Interpolation.maybe(interpolated_function,
                                    type=Function,
                                    function_name=LITERAL_FUNCTION)
     elif _token_ == 'FNCT':
         FNCT = self._scan('FNCT')
         LPAR = self._scan('LPAR')
         argspec = self.argspec()
         RPAR = self._scan('RPAR')
         return CallOp(FNCT, argspec)
     elif _token_ == 'BANG_IMPORTANT':
         BANG_IMPORTANT = self._scan('BANG_IMPORTANT')
         return Literal(String.unquoted("!important", literal=True))
     elif _token_ in self.atom_chks_:
         interpolated_bareword = self.interpolated_bareword()
         return Interpolation.maybe(interpolated_bareword)
     elif _token_ == 'NUM':
         NUM = self._scan('NUM')
         UNITS = None
         if self._peek(self.atom_rsts__) == 'UNITS':
             UNITS = self._scan('UNITS')
         return Literal(Number(float(NUM), unit=UNITS))
     elif _token_ not in self.atom_chks__:
         interpolated_string = self.interpolated_string()
         return interpolated_string
     elif _token_ == 'COLOR':
         COLOR = self._scan('COLOR')
         return Literal(Color.from_hex(COLOR, literal=True))
     else:  # == 'VAR'
         VAR = self._scan('VAR')
         return Variable(VAR)
Пример #13
0
 def atom(self):
     _token_ = self._peek(self.u_expr_chks)
     if _token_ == "LPAR":
         LPAR = self._scan("LPAR")
         _token_ = self._peek(self.atom_rsts)
         if _token_ == "RPAR":
             v = ListLiteral([], comma=False)
         else:  # in self.argspec_item_chks
             expr_map_or_list = self.expr_map_or_list()
             v = expr_map_or_list
         RPAR = self._scan("RPAR")
         return Parentheses(v)
     elif _token_ == "URL_FUNCTION":
         URL_FUNCTION = self._scan("URL_FUNCTION")
         LPAR = self._scan("LPAR")
         interpolated_url = self.interpolated_url()
         RPAR = self._scan("RPAR")
         return interpolated_url
     elif _token_ == "ALPHA_FUNCTION":
         ALPHA_FUNCTION = self._scan("ALPHA_FUNCTION")
         LPAR = self._scan("LPAR")
         _token_ = self._peek(self.atom_rsts_)
         if _token_ == '"opacity"':
             self._scan('"opacity"')
             self._scan('"="')
             NUM = self._scan("NUM")
             RPAR = self._scan("RPAR")
             return FunctionLiteral(Literal(String.unquoted("opacity=" + NUM)), "alpha")
         else:  # in self.atom_chks
             argspec = self.argspec()
             RPAR = self._scan("RPAR")
             return CallOp("alpha", argspec)
     elif _token_ == "LITERAL_FUNCTION":
         LITERAL_FUNCTION = self._scan("LITERAL_FUNCTION")
         LPAR = self._scan("LPAR")
         interpolated_function = self.interpolated_function()
         RPAR = self._scan("RPAR")
         return Interpolation.maybe(interpolated_function, type=Function, function_name=LITERAL_FUNCTION)
     elif _token_ == "FNCT":
         FNCT = self._scan("FNCT")
         LPAR = self._scan("LPAR")
         argspec = self.argspec()
         RPAR = self._scan("RPAR")
         return CallOp(FNCT, argspec)
     elif _token_ == "BANG_IMPORTANT":
         BANG_IMPORTANT = self._scan("BANG_IMPORTANT")
         return Literal(String.unquoted("!important", literal=True))
     elif _token_ in self.atom_chks_:
         interpolated_bareword = self.interpolated_bareword()
         return Interpolation.maybe(interpolated_bareword)
     elif _token_ == "NUM":
         NUM = self._scan("NUM")
         UNITS = None
         if self._peek(self.atom_rsts__) == "UNITS":
             UNITS = self._scan("UNITS")
         return Literal(Number(float(NUM), unit=UNITS))
     elif _token_ not in self.atom_chks__:
         interpolated_string = self.interpolated_string()
         return interpolated_string
     elif _token_ == "COLOR":
         COLOR = self._scan("COLOR")
         return Literal(Color.from_hex(COLOR, literal=True))
     else:  # == 'VAR'
         VAR = self._scan("VAR")
         return Variable(VAR)