]> git.saurik.com Git - apple/security.git/blame - libsecurity_codesigning/antlr2/src/TreeParser.cpp
Security-55471.14.18.tar.gz
[apple/security.git] / libsecurity_codesigning / antlr2 / src / TreeParser.cpp
CommitLineData
427c49bc
A
1/* ANTLR Translator Generator
2 * Project led by Terence Parr at http://www.jGuru.com
3 * Software rights: http://www.antlr.org/license.html
4 *
5 * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/TreeParser.cpp#2 $
6 */
7
8#include "antlr/TreeParser.hpp"
9#include "antlr/ASTNULLType.hpp"
10#include <stdio.h>
11
12#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
13namespace antlr {
14#endif
15
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
19 * everywhere.
20 */
21RefAST TreeParser::ASTNULL(new ASTNULLType);
22
23/** Parser error-reporting function can be overridden in subclass */
24void TreeParser::reportError(const RecognitionException& ex)
25{
26 fprintf(stderr, "%s", (ex.toString() + "\n").c_str());
27}
28
29/** Parser error-reporting function can be overridden in subclass */
30void TreeParser::reportError(const ANTLR_USE_NAMESPACE(std)string& s)
31{
32 fprintf(stderr, "%s", ("error: " + s + "\n").c_str());
33}
34
35/** Parser warning-reporting function can be overridden in subclass */
36void TreeParser::reportWarning(const ANTLR_USE_NAMESPACE(std)string& s)
37{
38 fprintf(stderr, "%s", ("warning: " + s + "\n").c_str());
39}
40
41/** Procedure to write out an indent for traceIn and traceOut */
42void TreeParser::traceIndent()
43{
44 for( int i = 0; i < traceDepth; i++ )
45 printf(" ");
46}
47
48void TreeParser::traceIn(const char* rname, RefAST t)
49{
50 traceDepth++;
51 traceIndent();
52
53 printf("%s",((ANTLR_USE_NAMESPACE(std)string)"> " + rname
54 + "(" + (t ? t->toString().c_str() : "null") + ")"
55 + ((inputState->guessing>0)?" [guessing]":"")
56 + "\n").c_str());
57}
58
59void TreeParser::traceOut(const char* rname, RefAST t)
60{
61 traceIndent();
62
63 printf("%s",((ANTLR_USE_NAMESPACE(std)string)"< " + rname
64 + "(" + (t ? t->toString().c_str() : "null") + ")"
65 + ((inputState->guessing>0)?" [guessing]":"")
66 + "\n").c_str());
67
68 traceDepth--;
69}
70
71#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
72}
73#endif