]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_codesigning/antlr2/src/TreeParser.cpp
1 /* ANTLR Translator Generator
2 * Project led by Terence Parr at http://www.jGuru.com
3 * Software rights: http://www.antlr.org/license.html
5 * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/TreeParser.cpp#2 $
8 #include "antlr/TreeParser.hpp"
9 #include "antlr/ASTNULLType.hpp"
12 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
16 /** The AST Null object; the parsing cursor is set to this when
17 * it is found to be null. This way, we can test the
18 * token type of a node without having to have tests for null
21 RefAST
TreeParser::ASTNULL(new ASTNULLType
);
23 /** Parser error-reporting function can be overridden in subclass */
24 void TreeParser::reportError(const RecognitionException
& ex
)
26 fprintf(stderr
, "%s", (ex
.toString() + "\n").c_str());
29 /** Parser error-reporting function can be overridden in subclass */
30 void TreeParser::reportError(const ANTLR_USE_NAMESPACE(std
)string
& s
)
32 fprintf(stderr
, "%s", ("error: " + s
+ "\n").c_str());
35 /** Parser warning-reporting function can be overridden in subclass */
36 void TreeParser::reportWarning(const ANTLR_USE_NAMESPACE(std
)string
& s
)
38 fprintf(stderr
, "%s", ("warning: " + s
+ "\n").c_str());
41 /** Procedure to write out an indent for traceIn and traceOut */
42 void TreeParser::traceIndent()
44 for( int i
= 0; i
< traceDepth
; i
++ )
48 void TreeParser::traceIn(const char* rname
, RefAST t
)
53 printf("%s",((ANTLR_USE_NAMESPACE(std
)string
)"> " + rname
54 + "(" + (t
? t
->toString().c_str() : "null") + ")"
55 + ((inputState
->guessing
>0)?" [guessing]":"")
59 void TreeParser::traceOut(const char* rname
, RefAST t
)
63 printf("%s",((ANTLR_USE_NAMESPACE(std
)string
)"< " + rname
64 + "(" + (t
? t
->toString().c_str() : "null") + ")"
65 + ((inputState
->guessing
>0)?" [guessing]":"")
71 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE