File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ public enum TargetsType {
91
91
protected int level = 0 ;
92
92
protected boolean callInvalidRules = false ;
93
93
94
+ private boolean isInteractive ;
95
+ private boolean parsingStarted ;
96
+
94
97
/**
95
98
* Indicates, whether there was found an error
96
99
*/
@@ -140,6 +143,7 @@ public ErrorCallback getErrorCallback() {
140
143
}
141
144
142
145
public SSTNode parse (InputType inputType ) {
146
+ isInteractive = inputType == InputType .SINGLE ;
143
147
SSTNode res = runParser (inputType );
144
148
if (res == null ) {
145
149
resetParserState ();
@@ -265,7 +269,13 @@ public Token getAndInitializeToken() {
265
269
}
266
270
reset (pos );
267
271
268
- // TODO: handle reaching end in single_input mode
272
+ if (isInteractive && token .type == Token .Kind .ENDMARKER && parsingStarted ) {
273
+ token .type = Token .Kind .NEWLINE ;
274
+ parsingStarted = false ;
275
+ // TODO: handle implicit DEDENT (PyPARSE_DONT_IMPLY_DEDENT)
276
+ } else {
277
+ parsingStarted = true ;
278
+ }
269
279
return initializeToken (token );
270
280
}
271
281
You can’t perform that action at this time.
0 commit comments