From b5ec911572aa0c07228fcb02976a8e848cc90391 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 10 Aug 2023 10:39:47 +0200 Subject: ANTLR Syntax: Add debugging facility for GnuCParser.g and StdCParser.g --- src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g | 20 +++++++++++++++----- src/antlr/com/jogamp/gluegen/cgram/StdCParser.g | 18 ++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) (limited to 'src/antlr/com') diff --git a/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g b/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g index bf01b12..88dbc1e 100644 --- a/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g +++ b/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g @@ -35,7 +35,9 @@ options exportVocab = GNUC; buildAST = true; ASTLabelType = "TNode"; - + + genHashLines = true; + // Copied following options from java grammar. codeGenMakeSwitchThreshold = 2; codeGenBitsetTestThreshold = 3; @@ -51,7 +53,7 @@ options // source for names to unnamed scopes protected int unnamedScopeCounter = 0; - + public boolean isTypedefName(String name) { boolean returnValue = false; TNode node = symbolTable.lookupNameInCurrentScope(name); @@ -77,6 +79,16 @@ options symbolTable.popScope(); } + protected boolean debugging = false; + + public boolean getDebug() { + return debugging; + } + + public void setDebug(boolean debug) { + this.debugging = debug; + } + int traceDepth = 0; public void reportError(RecognitionException ex) { try { @@ -94,9 +106,7 @@ options public void reportWarning(String s) { System.err.println("ANTLR Parsing Warning from String: " + s); } - public void match(int t) throws MismatchedTokenException { - boolean debugging = false; - + public void match(int t) throws MismatchedTokenException { if ( debugging ) { for (int x=0; x