]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_codesigning/antlr2/src/CharScanner.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/CharScanner.cpp#2 $
11 #include "antlr/CharScanner.hpp"
12 #include "antlr/CommonToken.hpp"
14 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
19 CharScanner::CharScanner(InputBuffer
& cb
, bool case_sensitive
)
20 : saveConsumedInput(true) //, caseSensitiveLiterals(true)
21 , caseSensitive(case_sensitive
)
22 , literals(CharScannerLiteralsLess(this))
23 , inputState(new LexerInputState(cb
))
28 setTokenObjectFactory(&CommonToken::factory
);
31 CharScanner::CharScanner(InputBuffer
* cb
, bool case_sensitive
)
32 : saveConsumedInput(true) //, caseSensitiveLiterals(true)
33 , caseSensitive(case_sensitive
)
34 , literals(CharScannerLiteralsLess(this))
35 , inputState(new LexerInputState(cb
))
40 setTokenObjectFactory(&CommonToken::factory
);
43 CharScanner::CharScanner( const LexerSharedInputState
& state
, bool case_sensitive
)
44 : saveConsumedInput(true) //, caseSensitiveLiterals(true)
45 , caseSensitive(case_sensitive
)
46 , literals(CharScannerLiteralsLess(this))
52 setTokenObjectFactory(&CommonToken::factory
);
55 /** Report exception errors caught in nextToken() */
56 void CharScanner::reportError(const RecognitionException
& ex
)
58 fprintf(stderr
, "%s", (ex
.toString() + "\n").c_str());
61 /** Parser error-reporting function can be overridden in subclass */
62 void CharScanner::reportError(const ANTLR_USE_NAMESPACE(std
)string
& s
)
64 if ( getFilename()=="" )
65 fprintf(stderr
, "%s", ("error: " + s
+ "\n").c_str());
67 fprintf(stderr
, "%s", (getFilename() + ": error: " + s
+ "\n").c_str());
70 /** Parser warning-reporting function can be overridden in subclass */
71 void CharScanner::reportWarning(const ANTLR_USE_NAMESPACE(std
)string
& s
)
73 if ( getFilename()=="" )
74 fprintf(stderr
, "%s", ("warning: " + s
+ "\n").c_str());
76 fprintf(stderr
, "%s", (getFilename() + ": warning: " + s
+ "\n").c_str());
79 void CharScanner::traceIndent()
81 for( int i
= 0; i
< traceDepth
; i
++ )
85 void CharScanner::traceIn(const char* rname
)
89 printf("> lexer %s; c==%d\n", rname
, LA(1));
92 void CharScanner::traceOut(const char* rname
)
95 printf("< lexer %s; c==%d\n", rname
, LA(1));
99 #ifndef NO_STATIC_CONSTS
100 const int CharScanner::NO_CHAR
;
101 const int CharScanner::EOF_CHAR
;
104 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE