mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
support line continuation character
This commit is contained in:
parent
d493d74cde
commit
31850d3f29
@ -315,6 +315,13 @@ static bool is_unicode_Lo_char(uint32_t c) {
|
|||||||
case '[': add_token(TK("[")); return true;
|
case '[': add_token(TK("[")); return true;
|
||||||
case ']': add_token(TK("]")); return true;
|
case ']': add_token(TK("]")); return true;
|
||||||
case '@': add_token(TK("@")); return true;
|
case '@': add_token(TK("@")); return true;
|
||||||
|
case '\\': {
|
||||||
|
// line continuation character
|
||||||
|
char c = eatchar_include_newline();
|
||||||
|
if (c != '\n') SyntaxError("expected newline after line continuation character");
|
||||||
|
eat_spaces();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case '$': {
|
case '$': {
|
||||||
for(int i=TK("$goto"); i<=TK("$label"); i++){
|
for(int i=TK("$goto"); i<=TK("$label"); i++){
|
||||||
// +1 to skip the '$'
|
// +1 to skip the '$'
|
||||||
|
31
tests/04_line_continue.py
Normal file
31
tests/04_line_continue.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
a = 1 + 2 \
|
||||||
|
+ 3
|
||||||
|
|
||||||
|
assert a == 6
|
||||||
|
|
||||||
|
assert 1 + 2 \
|
||||||
|
+ 3 == 6
|
||||||
|
|
||||||
|
assert 1 + 2 + \
|
||||||
|
3 + \
|
||||||
|
4 == 10
|
||||||
|
|
||||||
|
assert 1 + 2 + \
|
||||||
|
3 + \
|
||||||
|
4 + 5 + 6 \
|
||||||
|
== 21
|
||||||
|
|
||||||
|
if 1 and 2 \
|
||||||
|
and 3 \
|
||||||
|
and 4 \
|
||||||
|
and 5:
|
||||||
|
assert True
|
||||||
|
else:
|
||||||
|
assert False
|
||||||
|
|
||||||
|
1 and 2 \
|
||||||
|
and 3 \
|
||||||
|
and 4
|
||||||
|
|
||||||
|
a = 1
|
||||||
|
assert a == 1
|
Loading…
x
Reference in New Issue
Block a user