mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
string fun
This commit is contained in:
parent
ed6a5f4d91
commit
12b2ba3904
2 changed files with 19 additions and 1 deletions
|
@ -136,6 +136,17 @@ def test_times_div_mod():
|
|||
def test_times_div_mod_floor():
|
||||
yield check_ast, '42 * 65 / 6 % 28 // 13'
|
||||
|
||||
def test_str_str():
|
||||
yield check_ast, '"hello" \'mom\''
|
||||
|
||||
def test_str_plus_str():
|
||||
yield check_ast, '"hello" + \'mom\''
|
||||
|
||||
def test_str_times_int():
|
||||
yield check_ast, '"hello" * 20'
|
||||
|
||||
def test_int_times_str():
|
||||
yield check_ast, '2*"hello"'
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -133,7 +133,6 @@ class Parser(object):
|
|||
'pm_term',
|
||||
'op_factor',
|
||||
'trailer',
|
||||
'string_literal',
|
||||
'comma_subscript',
|
||||
'comma_expr_or_star_expr',
|
||||
'comma_test',
|
||||
|
@ -898,6 +897,14 @@ class Parser(object):
|
|||
cls = ast.Bytes if p[1].startswith('b') else ast.Str
|
||||
p[0] = cls(s=s, lineno=self.lineno, col_offset=self.col)
|
||||
|
||||
def p_string_literal_list(self, p):
|
||||
"""string_literal_list : string_literal
|
||||
| string_literal_list string_literal
|
||||
"""
|
||||
if len(p) == 3:
|
||||
p[1].s += p[2].s
|
||||
p[0] = p[1]
|
||||
|
||||
def p_number(self, p):
|
||||
"""number : INT_LITERAL
|
||||
| HEX_LITERAL
|
||||
|
|
Loading…
Add table
Reference in a new issue