diff options
author | Jack Palevich <jackpal@google.com> | 2009-06-08 15:55:32 -0700 |
---|---|---|
committer | Jack Palevich <jackpal@google.com> | 2009-06-08 15:55:32 -0700 |
commit | 36d9414f72b629dacc2c972e93d16cec08ef44b6 (patch) | |
tree | 37adc7a81e84320f9bf720febf58457daf495746 /libacc/acc.cpp | |
parent | 2d11dfba277b2f9d98f00a32510d612e779ba757 (diff) | |
download | system_core-36d9414f72b629dacc2c972e93d16cec08ef44b6.zip system_core-36d9414f72b629dacc2c972e93d16cec08ef44b6.tar.gz system_core-36d9414f72b629dacc2c972e93d16cec08ef44b6.tar.bz2 |
Make a host version of acc for testing.
Don't run the code we've compiled unless the -R option is present.
Diffstat (limited to 'libacc/acc.cpp')
-rw-r--r-- | libacc/acc.cpp | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/libacc/acc.cpp b/libacc/acc.cpp index a3a70d1..db37ee2 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -1087,26 +1087,6 @@ class Compiler : public ErrorSink { size_t mPosition; }; - int ch; // Current input character, or EOF - intptr_t tok; // token - intptr_t tokc; // token extra info - int tokl; // token operator level - intptr_t rsym; // return symbol - intptr_t loc; // local variable index - char* glo; // global variable index - char* sym_stk; - char* dstk; // Define stack - char* dptr; // Macro state: Points to macro text during macro playback. - int dch; // Macro state: Saves old value of ch during a macro playback. - char* last_id; - char* pGlobalBase; - char* pVarsBase; // Value of variables - - InputStream* file; - - CodeBuf codeBuf; - CodeGenerator* pGen; - class String { public: String() { @@ -1306,6 +1286,8 @@ class Compiler : public ErrorSink { void pop() { if (mUsed > 0) { mUsed -= 1; + } else { + error("internal error: Popped empty stack."); } } @@ -1338,7 +1320,34 @@ class Compiler : public ErrorSink { size_t mSize; }; + struct InputState { + InputStream* pStream; + int oldCh; + }; + + + int ch; // Current input character, or EOF + intptr_t tok; // token + intptr_t tokc; // token extra info + int tokl; // token operator level + intptr_t rsym; // return symbol + intptr_t loc; // local variable index + char* glo; // global variable index + char* sym_stk; + char* dstk; // Define stack + char* dptr; // Macro state: Points to macro text during macro playback. + int dch; // Macro state: Saves old value of ch during a macro playback. + char* last_id; + char* pGlobalBase; + char* pVarsBase; // Value of variables + + InputStream* file; + + CodeBuf codeBuf; + CodeGenerator* pGen; + MacroTable mMacros; + Array<InputState> mInputStateStack; String mErrorBuf; |