diff --git a/parser.ccc/src/main/ccc/Grammer.ccc b/parser.ccc/src/main/ccc/Grammer.ccc index 8db3524..4253ed2 100644 --- a/parser.ccc/src/main/ccc/Grammer.ccc +++ b/parser.ccc/src/main/ccc/Grammer.ccc @@ -22,6 +22,7 @@ NODE_PACKAGE = org.eclipse.daanse.mdx.parser.ccc.tree; TABS_TO_SPACES = 4; PRESERVE_TABS = true; NODE_PREFIX = "AST"; +TREE_BUILDING_ENABLED = false; COPYRIGHT_BLURB="\n*\n* Copyright (c) 2023 Contributors to the Eclipse Foundation.\n*\n* This program and the accompanying materials are made\n* available under the terms of the Eclipse Public License 2.0\n* which is available at https://www.eclipse.org/legal/epl-2.0/\n*\n* SPDX-License-Identifier: EPL-2.0\n*\n* Contributors: see corresponding .ccc file\n"; INJECT PARSER_CLASS : diff --git a/parser.ccc/src/main/java/org/eclipse/daanse/mdx/parser/ccc/MdxParserWrapper.java b/parser.ccc/src/main/java/org/eclipse/daanse/mdx/parser/ccc/MdxParserWrapper.java index 2b62d97..988e46e 100644 --- a/parser.ccc/src/main/java/org/eclipse/daanse/mdx/parser/ccc/MdxParserWrapper.java +++ b/parser.ccc/src/main/java/org/eclipse/daanse/mdx/parser/ccc/MdxParserWrapper.java @@ -15,9 +15,6 @@ import java.util.List; import java.util.Optional; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.nio.charset.StandardCharsets; import java.util.Set; import org.slf4j.Logger; @@ -99,8 +96,6 @@ public MdxStatement parseMdxStatement() throws MdxParserException { } catch (StackOverflowError e) { logger.debug("Failed to parse, nested too deep"); throw tooDeep(e); - } finally { - dump(); } } @@ -118,11 +113,11 @@ private static MdxParserException toMdxParserException(ParseException pe) { * text does not have. The statement ends right after its last token, so that is where it is reported. */ private static MdxParserException atToken(ParseException pe) { - Node.TerminalNode token = pe.getToken(); + Token token = pe.getToken(); String message = pe.getMessage(); int line = token.getBeginLine(); int column = token.getBeginColumn(); - Token last = token instanceof Token eof && eof.getType() == Token.TokenType.EOF ? eof.getPrevious() : null; + Token last = token.getType() == Token.TokenType.EOF ? token.getPrevious() : null; if (last != null) { line = last.getEndLine(); column = last.getEndColumn() + 1; @@ -132,26 +127,6 @@ private static MdxParserException atToken(ParseException pe) { return new MdxParserException(message, pe, line, column); } - private void dump() { - // Node.dump() writes the whole tree to System.out, so it has to be gated on the - // level like the message above it. Ungated, every parse printed its AST: ~177k - // lines per TCK test group, unreachable by any logging configuration. - if (!logger.isTraceEnabled()) { - return; - } - Node root = delegate.rootNode(); - if (root != null) { - // through the logger, not to System.out: the configuration decides where it goes - try { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - root.dump("", new PrintStream(buffer, false, StandardCharsets.UTF_8)); - logger.trace("parser AST:{}{}", System.lineSeparator(), buffer.toString(StandardCharsets.UTF_8)); - } catch (StackOverflowError e) { - logger.trace("parser AST is nested too deep to dump"); - } - } - } - /** * Every failure of a parse is a MdxParserException, also the stack that runs * out on input the nesting limit of the grammar did not stop. @@ -276,8 +251,6 @@ private T parse(String what, ParseAction action) throws MdxParserExceptio } catch (StackOverflowError e) { logger.debug("Failed to parse, nested too deep"); throw tooDeep(e); - } finally { - dump(); } } }