Search in sources :

Example 1 with StatementParsing

use of com.jetbrains.python.parsing.StatementParsing in project intellij-community by JetBrains.

the class PyConsoleParser method parse.

@NotNull
@Override
public ASTNode parse(IElementType root, PsiBuilder builder) {
    final PsiBuilder.Marker rootMarker = builder.mark();
    myIPythonStartSymbol = myPythonConsoleData.isIPythonEnabled() && startsWithIPythonSpecialSymbol(builder);
    ParsingContext context = createParsingContext(builder, myLanguageLevel, myFutureFlag);
    StatementParsing stmt_parser = context.getStatementParser();
    // must be done before touching the caching lexer with eof() call.
    builder.setTokenTypeRemapper(stmt_parser);
    while (!builder.eof()) {
        stmt_parser.parseStatement();
    }
    rootMarker.done(root);
    return builder.getTreeBuilt();
}
Also used : ParsingContext(com.jetbrains.python.parsing.ParsingContext) StatementParsing(com.jetbrains.python.parsing.StatementParsing) PsiBuilder(com.intellij.lang.PsiBuilder) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with StatementParsing

use of com.jetbrains.python.parsing.StatementParsing in project intellij-community by JetBrains.

the class IpnbPyParser method parse.

@NotNull
@Override
public ASTNode parse(IElementType root, PsiBuilder builder) {
    final PsiBuilder.Marker rootMarker = builder.mark();
    myIPythonStartSymbol = PyConsoleParser.startsWithIPythonSpecialSymbol(builder);
    ParsingContext context = createParsingContext(builder, myLanguageLevel, null);
    StatementParsing statementParser = context.getStatementParser();
    builder.setTokenTypeRemapper(statementParser);
    while (!builder.eof()) {
        statementParser.parseStatement();
    }
    rootMarker.done(root);
    return builder.getTreeBuilt();
}
Also used : ParsingContext(com.jetbrains.python.parsing.ParsingContext) StatementParsing(com.jetbrains.python.parsing.StatementParsing) PsiBuilder(com.intellij.lang.PsiBuilder) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiBuilder (com.intellij.lang.PsiBuilder)2 ParsingContext (com.jetbrains.python.parsing.ParsingContext)2 StatementParsing (com.jetbrains.python.parsing.StatementParsing)2 NotNull (org.jetbrains.annotations.NotNull)2