mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
support complex import
This commit is contained in:
parent
5888151182
commit
8b47a2001f
@ -20,7 +20,7 @@ constexpr const char* kTokens[] = {
|
||||
"<<", "<<=", ">>", ">>=",
|
||||
/*****************************************/
|
||||
".", ",", ":", ";", "#", "(", ")", "[", "]", "{", "}",
|
||||
"**", "=", ">", "<", "...", "->", "?", "@", "==", "!=", ">=", "<=",
|
||||
"**", "=", ">", "<", "..", "...", "->", "?", "@", "==", "!=", ">=", "<=",
|
||||
"++", "--", "~",
|
||||
/** SPEC_BEGIN **/
|
||||
"$goto", "$label",
|
||||
|
@ -502,7 +502,8 @@ __SUBSCR_END:
|
||||
|
||||
while(true){
|
||||
switch(curr().type){
|
||||
case TK("."): dots++; break;
|
||||
case TK("."): dots+=1; break;
|
||||
case TK(".."): dots+=2; break;
|
||||
case TK("..."): dots+=3; break;
|
||||
default: goto __EAT_DOTS_END;
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ static bool is_unicode_Lo_char(uint32_t c) {
|
||||
if(matchchar('.')) {
|
||||
add_token(TK("..."));
|
||||
} else {
|
||||
SyntaxError("invalid token '..'");
|
||||
add_token(TK(".."));
|
||||
}
|
||||
} else {
|
||||
add_token(TK("."));
|
||||
|
@ -6,3 +6,12 @@ except ImportError:
|
||||
import test1
|
||||
|
||||
assert test1.add(1, 2) == 13
|
||||
|
||||
from test2.a.g import get_value
|
||||
assert get_value() == '123'
|
||||
|
||||
import test2
|
||||
assert test2.a.g.get_value() == '123'
|
||||
|
||||
from test2.utils import get_value_2
|
||||
assert get_value_2() == '123'
|
@ -1 +1 @@
|
||||
from ._a import D
|
||||
from .a import D
|
@ -1 +0,0 @@
|
||||
from ._b import D
|
1
tests/test2/a/__init__.py
Normal file
1
tests/test2/a/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from ..b import D
|
4
tests/test2/a/g/__init__.py
Normal file
4
tests/test2/a/g/__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
from ...utils import r
|
||||
|
||||
def get_value():
|
||||
return r.value
|
@ -1,7 +1,7 @@
|
||||
D = 10
|
||||
|
||||
try:
|
||||
import test
|
||||
import abc # does not exist
|
||||
exit(1)
|
||||
except ImportError:
|
||||
pass
|
4
tests/test2/utils/__init__.py
Normal file
4
tests/test2/utils/__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
from .r import value
|
||||
|
||||
def get_value_2():
|
||||
return value
|
7
tests/test2/utils/r.py
Normal file
7
tests/test2/utils/r.py
Normal file
@ -0,0 +1,7 @@
|
||||
value = '123'
|
||||
|
||||
try:
|
||||
from test2.a import g
|
||||
except ImportError:
|
||||
# circular import
|
||||
pass
|
Loading…
x
Reference in New Issue
Block a user