├── .gitignore ├── BUILD ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── WORKSPACE ├── alpine └── Dockerfile ├── build-dist.sh ├── build.sh ├── schema ├── BUILD └── data.proto ├── src ├── README.md ├── agent │ ├── BUILD │ ├── Makefile │ ├── agent_thread.h │ ├── array_expression_evaluator.cc │ ├── array_expression_evaluator.h │ ├── array_reader.h │ ├── array_type_evaluator.h │ ├── auto_jvmti_breakpoint.cc │ ├── auto_jvmti_breakpoint.h │ ├── auto_reset_event.h │ ├── binary_expression_evaluator.cc │ ├── binary_expression_evaluator.h │ ├── breakpoint.h │ ├── breakpoint_labels_provider.h │ ├── breakpoints_manager.h │ ├── bridge.h │ ├── byte_source.h │ ├── callbacks_monitor.cc │ ├── callbacks_monitor.h │ ├── canary_control.cc │ ├── canary_control.h │ ├── capture_data_collector.cc │ ├── capture_data_collector.h │ ├── cdbg_java_agent.lds │ ├── class_file.cc │ ├── class_file.h │ ├── class_files_cache.cc │ ├── class_files_cache.h │ ├── class_indexer.h │ ├── class_metadata_reader.h │ ├── class_path_lookup.h │ ├── common.h │ ├── conditional_operator_evaluator.cc │ ├── conditional_operator_evaluator.h │ ├── config.cc │ ├── config.h │ ├── config_builder.cc │ ├── config_builder.h │ ├── data_visibility_policy.h │ ├── data_visibility_scrubbed_eval_call_stack.cc │ ├── data_visibility_scrubbed_eval_call_stack.h │ ├── debuggee_labels.cc │ ├── debuggee_labels.h │ ├── debugger.cc │ ├── debugger.h │ ├── dynamic_logger.h │ ├── encoding_util.cc │ ├── encoding_util.h │ ├── eval_call_stack.h │ ├── expression_evaluator.h │ ├── expression_util.cc │ ├── expression_util.h │ ├── field_evaluator.cc │ ├── field_evaluator.h │ ├── format-env-appengine-vm.sh │ ├── format_queue.cc │ ├── format_queue.h │ ├── generic_type_evaluator.cc │ ├── generic_type_evaluator.h │ ├── glob_data_visibility_policy.cc │ ├── glob_data_visibility_policy.h │ ├── identifier_evaluator.cc │ ├── identifier_evaluator.h │ ├── instance_field_reader.h │ ├── instanceof_binary_expression_evaluator.cc │ ├── instanceof_binary_expression_evaluator.h │ ├── internals-class-loader │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── google │ │ │ │ └── devtools │ │ │ │ └── cdbg │ │ │ │ └── debuglets │ │ │ │ └── java │ │ │ │ ├── BUILD │ │ │ │ └── InternalsClassLoader.java │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── google │ │ │ └── devtools │ │ │ └── cdbg │ │ │ └── debuglets │ │ │ └── java │ │ │ ├── BUILD │ │ │ └── InternalsClassLoaderTest.java │ ├── internals │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── google │ │ │ │ └── devtools │ │ │ │ └── cdbg │ │ │ │ └── debuglets │ │ │ │ └── java │ │ │ │ ├── AgentLogger.java │ │ │ │ ├── AppPathLookup.java │ │ │ │ ├── BUILD │ │ │ │ ├── BreakpointLabelsProvider.java │ │ │ │ ├── ClassPathLookup.java │ │ │ │ ├── ClassResourcesIndexer.java │ │ │ │ ├── DataTypeConverter.java │ │ │ │ ├── DynamicLogHelper.java │ │ │ │ ├── EmbedClassLoader.java │ │ │ │ ├── FirebaseClient.java │ │ │ │ ├── FormatMessage.java │ │ │ │ ├── GceMetadataQuery.java │ │ │ │ ├── GcpBreakpointLabelsProvider.java │ │ │ │ ├── GcpDebugletVersion.java │ │ │ │ ├── GcpEnvironment.java │ │ │ │ ├── HubClient.java │ │ │ │ ├── Labels.java │ │ │ │ ├── Messages.java │ │ │ │ ├── MetadataQuery.java │ │ │ │ ├── ProxyObjectBase.java │ │ │ │ ├── ResolvedSourceLocation.java │ │ │ │ ├── ResourceIndexer.java │ │ │ │ ├── ResourcesDatabase.java │ │ │ │ ├── SafeCallerException.java │ │ │ │ ├── ServiceAccountAuth.java │ │ │ │ ├── SourceFileMapper.java │ │ │ │ ├── Statistician.java │ │ │ │ ├── UniquifierComputer.java │ │ │ │ ├── UserIdProvider.java │ │ │ │ ├── YamlConfigParser.java │ │ │ │ └── YamlConfigParserException.java │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── google │ │ │ └── devtools │ │ │ └── cdbg │ │ │ └── debuglets │ │ │ └── java │ │ │ ├── AgentLoggerTest.java │ │ │ ├── BUILD │ │ │ ├── BreakpointDefinition.java │ │ │ ├── BreakpointDefinitionTest.java │ │ │ ├── BreakpointTagException.java │ │ │ ├── ClassFileTextifier.java │ │ │ ├── ClassPathLookupTest.java │ │ │ ├── DataTypeConverterTest.java │ │ │ ├── DynamicJarClass.java │ │ │ ├── FirebaseClientTest.java │ │ │ ├── GceMetadataQueryTest.java │ │ │ ├── GcpEnvironmentTest.java │ │ │ ├── NanoJavaInterpreterTestLib.java │ │ │ ├── TestDataPath.java │ │ │ └── YamlConfigParserTest.java │ ├── iterable_type_evaluator.cc │ ├── iterable_type_evaluator.h │ ├── java_expression.cc │ ├── java_expression.g │ ├── java_expression.h │ ├── jni_breakpoint_labels_provider.cc │ ├── jni_breakpoint_labels_provider.h │ ├── jni_bridge.cc │ ├── jni_bridge.h │ ├── jni_flags.cc │ ├── jni_logger.cc │ ├── jni_method_caller.cc │ ├── jni_method_caller.h │ ├── jni_semaphore.cc │ ├── jni_semaphore.h │ ├── jni_user_id_provider.cc │ ├── jni_user_id_provider.h │ ├── jni_utils.cc │ ├── jni_utils.h │ ├── jobject_map.h │ ├── jsoncpp_util.cc │ ├── jsoncpp_util.h │ ├── jvariant.cc │ ├── jvariant.h │ ├── jvm_breakpoint.cc │ ├── jvm_breakpoint.h │ ├── jvm_breakpoints_manager.cc │ ├── jvm_breakpoints_manager.h │ ├── jvm_class_indexer.cc │ ├── jvm_class_indexer.h │ ├── jvm_class_metadata_reader.cc │ ├── jvm_class_metadata_reader.h │ ├── jvm_dynamic_logger.cc │ ├── jvm_dynamic_logger.h │ ├── jvm_env.cc │ ├── jvm_env.h │ ├── jvm_eval_call_stack.cc │ ├── jvm_eval_call_stack.h │ ├── jvm_evaluators.h │ ├── jvm_instance_field_reader.cc │ ├── jvm_instance_field_reader.h │ ├── jvm_internals.cc │ ├── jvm_internals.h │ ├── jvm_local_variable_reader.cc │ ├── jvm_local_variable_reader.h │ ├── jvm_object_array_reader.h │ ├── jvm_object_evaluator.cc │ ├── jvm_object_evaluator.h │ ├── jvm_primitive_array_reader.h │ ├── jvm_readers_factory.cc │ ├── jvm_readers_factory.h │ ├── jvm_static_field_reader.cc │ ├── jvm_static_field_reader.h │ ├── jvmti_agent.cc │ ├── jvmti_agent.h │ ├── jvmti_agent_thread.cc │ ├── jvmti_agent_thread.h │ ├── jvmti_buffer.h │ ├── jvmti_globals.cc │ ├── leaky_bucket.cc │ ├── leaky_bucket.h │ ├── legacy_flags.cc │ ├── literal_evaluator.h │ ├── local_variable_reader.h │ ├── log_data_collector.cc │ ├── log_data_collector.h │ ├── map_entry_type_evaluator.cc │ ├── map_entry_type_evaluator.h │ ├── map_type_evaluator.cc │ ├── map_type_evaluator.h │ ├── messages.h │ ├── method_call_evaluator.cc │ ├── method_call_evaluator.h │ ├── method_call_result.h │ ├── method_caller.h │ ├── method_locals.cc │ ├── method_locals.h │ ├── model.h │ ├── model_json.cc │ ├── model_json.h │ ├── model_util.h │ ├── multi_data_visibility_policy.cc │ ├── multi_data_visibility_policy.h │ ├── mutex.h │ ├── nanojava_internal_error_builder.h │ ├── nanojava_interpreter.cc │ ├── nanojava_interpreter.h │ ├── nanojava_locals.cc │ ├── nanojava_locals.h │ ├── nanojava_slot.h │ ├── nanojava_stack.cc │ ├── nanojava_stack.h │ ├── nullable.h │ ├── numeric_cast_evaluator.h │ ├── object_evaluator.h │ ├── observable.h │ ├── rate_limit.cc │ ├── rate_limit.h │ ├── readers_factory.h │ ├── resolved_source_location.h │ ├── safe_caller_proxies.cc │ ├── safe_caller_proxies.h │ ├── safe_method_caller.cc │ ├── safe_method_caller.h │ ├── scheduler.cc │ ├── scheduler.h │ ├── semaphore.h │ ├── service-account-auth │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── google │ │ │ └── devtools │ │ │ └── cdbg │ │ │ └── ServiceAccountAuthTool.java │ ├── static_field_reader.h │ ├── statistician.cc │ ├── statistician.h │ ├── stopwatch.h │ ├── string_evaluator.cc │ ├── string_evaluator.h │ ├── stringable_type_evaluator.cc │ ├── stringable_type_evaluator.h │ ├── structured_data_visibility_policy.cc │ ├── structured_data_visibility_policy.h │ ├── transmit_queue.h │ ├── type_cast_operator_evaluator.cc │ ├── type_cast_operator_evaluator.h │ ├── type_evaluator.h │ ├── type_util.cc │ ├── type_util.h │ ├── unary_expression_evaluator.cc │ ├── unary_expression_evaluator.h │ ├── user_id_provider.h │ ├── value_formatter.cc │ ├── value_formatter.h │ ├── worker.cc │ ├── worker.h │ ├── yaml_data_visibility_config_reader.cc │ └── yaml_data_visibility_config_reader.h └── codegen │ ├── BUILD │ ├── config-test.json │ ├── config.json │ ├── pom.xml │ ├── src │ └── main │ │ └── java │ │ └── devtools │ │ └── cdbg │ │ └── debuglets │ │ └── java │ │ └── codegen │ │ ├── BUILD │ │ ├── Config.java │ │ ├── JniProxy.cc.tpl │ │ ├── JniProxy.h.tpl │ │ ├── JniProxyCodeGen.java │ │ └── Mock.h.tpl │ └── static_def_gen.py ├── tests └── agent │ ├── BUILD │ ├── array_type_evaluator_test.cc │ ├── auto_jvmti_breakpoint_test.cc │ ├── build_defs.bzl │ ├── byte_source_test.cc │ ├── callbacks_monitor_test.cc │ ├── canary_control_test.cc │ ├── capture_data_collector_test.cc │ ├── class_file_test.cc │ ├── class_files_cache_test.cc │ ├── config_builder_test.cc │ ├── config_test.cc │ ├── data_visibility_scrubbed_eval_call_stack_test.cc │ ├── debuggee_labels_test.cc │ ├── encoding_util_test.cc │ ├── expressions_test.cc │ ├── fake_instance_field_reader.h │ ├── fake_jni.cc │ ├── fake_jni.h │ ├── fake_local_variable_reader.h │ ├── fake_static_field_reader.h │ ├── file_utils.cc │ ├── file_utils.h │ ├── format_queue_test.cc │ ├── generic_type_evaluator_test.cc │ ├── glob_data_visibility_policy_test.cc │ ├── jasmin_utils.cc │ ├── jasmin_utils.h │ ├── java_expression_parser_test.cc │ ├── jni_method_caller_test.cc │ ├── jni_utils_test.cc │ ├── jobject_map_test.cc │ ├── json_eq_matcher.h │ ├── jsoncpp_util_test.cc │ ├── jvariant_test.cc │ ├── jvm_breakpoint_test.cc │ ├── jvm_breakpoints_manager_test.cc │ ├── jvm_class_indexer_test.cc │ ├── jvm_class_metadata_reader_test.cc │ ├── jvm_eval_call_stack_test.cc │ ├── jvm_instance_field_reader_test.cc │ ├── jvm_internals_test.cc │ ├── jvm_local_variable_reader_test.cc │ ├── jvm_object_array_reader_test.cc │ ├── jvm_object_evaluator_test.cc │ ├── jvm_primitive_array_reader_test.cc │ ├── jvm_static_field_reader_test.cc │ ├── jvm_test_base.cc │ ├── log_data_collector_test.cc │ ├── method_locals_test.cc │ ├── mock_array_reader.h │ ├── mock_breakpoint.h │ ├── mock_breakpoint_labels_provider.h │ ├── mock_breakpoints_manager.h │ ├── mock_bridge.h │ ├── mock_class_indexer.h │ ├── mock_class_metadata_reader.h │ ├── mock_class_path_lookup.h │ ├── mock_data_visibility_policy.h │ ├── mock_dynamic_logger.h │ ├── mock_eval_call_stack.h │ ├── mock_jni_env.h │ ├── mock_jvmti_env.cc │ ├── mock_jvmti_env.h │ ├── mock_method_caller.h │ ├── mock_nanojava_internal_error_provider.h │ ├── mock_object_evaluator.h │ ├── mock_readers_factory.h │ ├── mock_user_id_provider.h │ ├── mock_worker_provider.h │ ├── model_json_test.cc │ ├── model_util_test.cc │ ├── multi_data_visibility_policy_test.cc │ ├── named_jvariant_test_util.cc │ ├── named_jvariant_test_util.h │ ├── nanojava_interpreter_test.cc │ ├── nanojava_locals_test.cc │ ├── nanojava_stack_test.cc │ ├── observable_test.cc │ ├── scheduler_test.cc │ ├── statistician_test.cc │ ├── structured_data_visibility_policy_test.cc │ ├── test_logger.cc │ ├── type_util_test.cc │ ├── value_formatter_test.cc │ ├── worker_test.cc │ └── yaml_data_visibility_config_reader_test.cc └── third_party ├── antlr ├── BUILD ├── LICENSE.txt ├── Makefile ├── README.md ├── antlr.patch ├── antlr │ ├── ANTLRError.java │ ├── ANTLRException.java │ ├── ANTLRGrammarParseBehavior.java │ ├── ANTLRHashString.java │ ├── ANTLRLexer.java │ ├── ANTLRParser.java │ ├── ANTLRStringBuffer.java │ ├── ANTLRTokdefLexer.java │ ├── ANTLRTokdefParser.java │ ├── ANTLRTokdefParserTokenTypes.java │ ├── ANTLRTokenTypes.java │ ├── ASTFactory.java │ ├── ASTIterator.java │ ├── ASTNULLType.java │ ├── ASTPair.java │ ├── ASTVisitor.java │ ├── ASdebug │ │ ├── ASDebugStream.java │ │ ├── IASDebugStream.java │ │ └── TokenOffsetInfo.java │ ├── ActionElement.java │ ├── ActionTransInfo.java │ ├── Alternative.java │ ├── AlternativeBlock.java │ ├── AlternativeElement.java │ ├── BaseAST.java │ ├── BlockContext.java │ ├── BlockEndElement.java │ ├── BlockWithImpliedExitPath.java │ ├── ByteBuffer.java │ ├── CSharpBlockFinishingInfo.java │ ├── CSharpCharFormatter.java │ ├── CSharpCodeGenerator.java │ ├── CSharpNameSpace.java │ ├── CharBuffer.java │ ├── CharFormatter.java │ ├── CharLiteralElement.java │ ├── CharQueue.java │ ├── CharRangeElement.java │ ├── CharScanner.java │ ├── CharStreamException.java │ ├── CharStreamIOException.java │ ├── CodeGenerator.java │ ├── CommonAST.java │ ├── CommonASTWithHiddenTokens.java │ ├── CommonHiddenStreamToken.java │ ├── CommonToken.java │ ├── CppBlockFinishingInfo.java │ ├── CppCharFormatter.java │ ├── CppCodeGenerator.java │ ├── DefaultFileLineFormatter.java │ ├── DefaultJavaCodeGeneratorPrintWriterManager.java │ ├── DefaultToolErrorHandler.java │ ├── DefineGrammarSymbols.java │ ├── DiagnosticCodeGenerator.java │ ├── DocBookCodeGenerator.java │ ├── DumpASTVisitor.java │ ├── ExceptionHandler.java │ ├── ExceptionSpec.java │ ├── FileCopyException.java │ ├── FileLineFormatter.java │ ├── Grammar.java │ ├── GrammarAnalyzer.java │ ├── GrammarAtom.java │ ├── GrammarElement.java │ ├── GrammarSymbol.java │ ├── HTMLCodeGenerator.java │ ├── ImportVocabTokenManager.java │ ├── InputBuffer.java │ ├── JavaBlockFinishingInfo.java │ ├── JavaCharFormatter.java │ ├── JavaCodeGenerator.java │ ├── JavaCodeGeneratorPrintWriterManager.java │ ├── LLkAnalyzer.java │ ├── LLkGrammarAnalyzer.java │ ├── LLkParser.java │ ├── LexerGrammar.java │ ├── LexerSharedInputState.java │ ├── Lookahead.java │ ├── MakeGrammar.java │ ├── MismatchedCharException.java │ ├── MismatchedTokenException.java │ ├── NameSpace.java │ ├── NoViableAltException.java │ ├── NoViableAltForCharException.java │ ├── OneOrMoreBlock.java │ ├── ParseTree.java │ ├── ParseTreeRule.java │ ├── ParseTreeToken.java │ ├── Parser.java │ ├── ParserGrammar.java │ ├── ParserSharedInputState.java │ ├── PreservingFileWriter.java │ ├── PrintWriterWithSMAP.java │ ├── PythonBlockFinishingInfo.java │ ├── PythonCharFormatter.java │ ├── PythonCodeGenerator.java │ ├── RecognitionException.java │ ├── RuleBlock.java │ ├── RuleEndElement.java │ ├── RuleRefElement.java │ ├── RuleSymbol.java │ ├── SemanticException.java │ ├── SimpleTokenManager.java │ ├── StringLiteralElement.java │ ├── StringLiteralSymbol.java │ ├── StringUtils.java │ ├── SynPredBlock.java │ ├── Token.java │ ├── TokenBuffer.java │ ├── TokenManager.java │ ├── TokenQueue.java │ ├── TokenRangeElement.java │ ├── TokenRefElement.java │ ├── TokenStream.java │ ├── TokenStreamBasicFilter.java │ ├── TokenStreamException.java │ ├── TokenStreamHiddenTokenFilter.java │ ├── TokenStreamIOException.java │ ├── TokenStreamRecognitionException.java │ ├── TokenStreamRetryException.java │ ├── TokenStreamRewriteEngine.java │ ├── TokenStreamSelector.java │ ├── TokenSymbol.java │ ├── TokenWithIndex.java │ ├── Tool.java │ ├── ToolErrorHandler.java │ ├── TreeBlockContext.java │ ├── TreeElement.java │ ├── TreeParser.java │ ├── TreeParserSharedInputState.java │ ├── TreeSpecifierNode.java │ ├── TreeWalkerGrammar.java │ ├── Utils.java │ ├── Version.java │ ├── Version.java.in │ ├── WildcardElement.java │ ├── ZeroOrMoreBlock.java │ ├── actions │ │ ├── cpp │ │ │ ├── ActionLexer.java │ │ │ ├── ActionLexerTokenTypes.java │ │ │ └── action.g │ │ ├── csharp │ │ │ ├── ActionLexer.java │ │ │ ├── ActionLexerTokenTypes.java │ │ │ └── action.g │ │ ├── java │ │ │ ├── ActionLexer.java │ │ │ ├── ActionLexerTokenTypes.java │ │ │ └── action.g │ │ └── python │ │ │ ├── ActionLexer.java │ │ │ ├── ActionLexerTokenTypes.java │ │ │ ├── CodeLexer.java │ │ │ ├── CodeLexerTokenTypes.java │ │ │ ├── action.g │ │ │ └── code.g │ ├── antlr.g │ ├── build │ │ ├── ANTLR.java │ │ ├── StreamScarfer.java │ │ └── Tool.java │ ├── collections │ │ ├── AST.java │ │ ├── ASTEnumeration.java │ │ ├── Enumerator.java │ │ ├── List.java │ │ ├── Stack.java │ │ └── impl │ │ │ ├── ASTArray.java │ │ │ ├── ASTEnumerator.java │ │ │ ├── BitSet.java │ │ │ ├── IndexedVector.java │ │ │ ├── IntRange.java │ │ │ ├── LLCell.java │ │ │ ├── LLEnumeration.java │ │ │ ├── LList.java │ │ │ ├── Vector.java │ │ │ ├── VectorEnumeration.java │ │ │ └── VectorEnumerator.java │ ├── debug │ │ ├── DebuggingCharScanner.java │ │ ├── DebuggingInputBuffer.java │ │ ├── DebuggingParser.java │ │ ├── Event.java │ │ ├── GuessingEvent.java │ │ ├── InputBufferAdapter.java │ │ ├── InputBufferEvent.java │ │ ├── InputBufferEventSupport.java │ │ ├── InputBufferListener.java │ │ ├── InputBufferReporter.java │ │ ├── LLkDebuggingParser.java │ │ ├── ListenerBase.java │ │ ├── MessageAdapter.java │ │ ├── MessageEvent.java │ │ ├── MessageListener.java │ │ ├── NewLineEvent.java │ │ ├── NewLineListener.java │ │ ├── ParseTreeDebugParser.java │ │ ├── ParserAdapter.java │ │ ├── ParserController.java │ │ ├── ParserEventSupport.java │ │ ├── ParserListener.java │ │ ├── ParserMatchAdapter.java │ │ ├── ParserMatchEvent.java │ │ ├── ParserMatchListener.java │ │ ├── ParserReporter.java │ │ ├── ParserTokenAdapter.java │ │ ├── ParserTokenEvent.java │ │ ├── ParserTokenListener.java │ │ ├── SemanticPredicateAdapter.java │ │ ├── SemanticPredicateEvent.java │ │ ├── SemanticPredicateListener.java │ │ ├── SyntacticPredicateAdapter.java │ │ ├── SyntacticPredicateEvent.java │ │ ├── SyntacticPredicateListener.java │ │ ├── TraceAdapter.java │ │ ├── TraceEvent.java │ │ ├── TraceListener.java │ │ ├── Tracer.java │ │ └── misc │ │ │ ├── ASTFrame.java │ │ │ ├── JTreeASTModel.java │ │ │ └── JTreeASTPanel.java │ ├── preprocessor │ │ ├── Grammar.java │ │ ├── GrammarFile.java │ │ ├── Hierarchy.java │ │ ├── Option.java │ │ ├── Preprocessor.java │ │ ├── PreprocessorLexer.java │ │ ├── PreprocessorTokenTypes.java │ │ ├── Rule.java │ │ ├── Tool.java │ │ └── preproc.g │ └── tokdef.g └── lib │ └── cpp │ ├── AUTHORS │ ├── README │ ├── antlr │ ├── ANTLRException.hpp │ ├── ANTLRUtil.hpp │ ├── AST.hpp │ ├── ASTArray.hpp │ ├── ASTFactory.hpp │ ├── ASTNULLType.hpp │ ├── ASTPair.hpp │ ├── ASTRefCount.hpp │ ├── BUILD │ ├── BaseAST.hpp │ ├── BitSet.hpp │ ├── CharBuffer.hpp │ ├── CharInputBuffer.hpp │ ├── CharScanner.hpp │ ├── CharStreamException.hpp │ ├── CharStreamIOException.hpp │ ├── CircularQueue.hpp │ ├── CommonAST.hpp │ ├── CommonASTWithHiddenTokens.hpp │ ├── CommonHiddenStreamToken.hpp │ ├── CommonToken.hpp │ ├── IOException.hpp │ ├── InputBuffer.hpp │ ├── LLkParser.hpp │ ├── LexerSharedInputState.hpp │ ├── Makefile.in │ ├── MismatchedCharException.hpp │ ├── MismatchedTokenException.hpp │ ├── NoViableAltException.hpp │ ├── NoViableAltForCharException.hpp │ ├── Parser.hpp │ ├── ParserSharedInputState.hpp │ ├── RecognitionException.hpp │ ├── RefCount.hpp │ ├── SemanticException.hpp │ ├── String.hpp │ ├── Token.hpp │ ├── TokenBuffer.hpp │ ├── TokenRefCount.hpp │ ├── TokenStream.hpp │ ├── TokenStreamBasicFilter.hpp │ ├── TokenStreamException.hpp │ ├── TokenStreamHiddenTokenFilter.hpp │ ├── TokenStreamIOException.hpp │ ├── TokenStreamRecognitionException.hpp │ ├── TokenStreamRetryException.hpp │ ├── TokenStreamRewriteEngine.hpp │ ├── TokenStreamSelector.hpp │ ├── TokenWithIndex.hpp │ ├── TreeParser.hpp │ ├── TreeParserSharedInputState.hpp │ └── config.hpp │ └── src │ ├── ANTLRUtil.cpp │ ├── ASTFactory.cpp │ ├── ASTNULLType.cpp │ ├── ASTRefCount.cpp │ ├── BUILD │ ├── BaseAST.cpp │ ├── BitSet.cpp │ ├── CharBuffer.cpp │ ├── CharScanner.cpp │ ├── CommonAST.cpp │ ├── CommonASTWithHiddenTokens.cpp │ ├── CommonHiddenStreamToken.cpp │ ├── CommonToken.cpp │ ├── InputBuffer.cpp │ ├── LLkParser.cpp │ ├── MismatchedCharException.cpp │ ├── MismatchedTokenException.cpp │ ├── NoViableAltException.cpp │ ├── NoViableAltForCharException.cpp │ ├── Parser.cpp │ ├── RecognitionException.cpp │ ├── String.cpp │ ├── Token.cpp │ ├── TokenBuffer.cpp │ ├── TokenRefCount.cpp │ ├── TokenStreamBasicFilter.cpp │ ├── TokenStreamHiddenTokenFilter.cpp │ ├── TokenStreamRewriteEngine.cpp │ ├── TokenStreamSelector.cpp │ ├── TreeParser.cpp │ └── dll.cpp └── jar_splitter ├── README.md ├── pom.xml └── src └── main └── java └── com └── google ├── appengine └── tools │ └── util │ ├── JarMaker.java │ └── JarSplitter.java └── devtools └── cdbg └── debuglets └── java └── JarSplitterMain.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *.gz 3 | *.jar 4 | *.o 5 | *.so 6 | 7 | # Ignore all bazel-* symlinks. There is no full list since this can change 8 | # based on the name of the directory bazel is cloned into. 9 | /bazel-* 10 | 11 | # These are required since running build.sh generates output in the source tree 12 | # itself. If this gets fixed at some point, these rules can be removed. 13 | dist/ 14 | src/agent/antlrgen 15 | src/agent/internals_class_loader_static_defs.inl 16 | src/agent/version.txt 17 | src/codegen/target 18 | src/codegen/*.cc 19 | src/codegen/*.h 20 | third_party/gflags* 21 | third_party/glog* 22 | third_party/install 23 | third_party/jsoncpp* 24 | 25 | # Maven build output 26 | target/ 27 | -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "jdk_headers", 5 | srcs = [ 6 | "@bazel_tools//tools/jdk:current_java_runtime" 7 | ], 8 | includes = [ 9 | "external/local_jdk/include", 10 | "external/local_jdk/include/linux", 11 | ], 12 | linkstatic = 1, 13 | visibility = [ 14 | "//visibility:public", 15 | ], 16 | ) 17 | 18 | java_library( 19 | name = "jasmin", 20 | runtime_deps = [ 21 | "@jasmin//jar", 22 | "@maven//:com_github_vbmacher_java_cup", 23 | ] 24 | ) 25 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor and submit your own code 2 | 3 | ## Contributor License Agreements 4 | 5 | We'd love to accept your patches! Before we can take them, we have to jump a couple of legal hurdles. 6 | 7 | Please fill out either the individual or corporate Contributor License Agreement (CLA). 8 | 9 | * If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html). 10 | * If you work for a company that wants to allow you to contribute your work, then you'll need to sign a [corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html). 11 | 12 | Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll be able to accept your pull requests. 13 | 14 | ## Contributing A Patch 15 | 16 | 1. Submit an issue describing your proposed change to the repo in question. 17 | 2. The repo owner will respond to your issue promptly. 18 | 3. If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above). 19 | 4. Fork the desired repo, develop and test your code changes. 20 | 5. Submit a pull request. 21 | -------------------------------------------------------------------------------- /alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | # WARNING: Stackdriver Debugger is not regularly tested on the Alpine Linux 2 | # platform and support will be on a best effort basis. 3 | # Sample Alpine Linux image including Java 8 and the Stackdriver Debugger agent. 4 | # The final image size should be around 90 MiB. 5 | 6 | # Stage 1: Build the agent. 7 | FROM alpine:latest 8 | 9 | RUN apk --no-cache add bash git curl gcc g++ make cmake python maven openjdk8 10 | RUN git clone https://github.com/GoogleCloudPlatform/cloud-debug-java 11 | 12 | WORKDIR cloud-debug-java 13 | RUN bash build.sh 14 | RUN mkdir -p /opt/cdbg 15 | RUN tar -xvf cdbg_java_agent_service_account.tar.gz -C /opt/cdbg 16 | 17 | 18 | # Stage 2: Create a minimal image with just Java and the debugger agent. 19 | FROM alpine:latest 20 | 21 | RUN apk --no-cache add openjdk8-jre 22 | COPY --from=0 /opt/cdbg /opt/cdbg 23 | -------------------------------------------------------------------------------- /build-dist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | DOCKER_IMAGE='ubuntu:16.04' 4 | 5 | docker pull "$DOCKER_IMAGE" 6 | docker container run -t --rm -v "$(pwd)":/io --env INSTALL_DEPS=1 "$DOCKER_IMAGE" /io/build.sh 7 | -------------------------------------------------------------------------------- /schema/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_proto_library") 2 | load("@rules_proto//proto:defs.bzl", "proto_library") 3 | 4 | package(default_visibility = ["//visibility:public"]) 5 | 6 | java_proto_library( 7 | name = "data_java_proto", 8 | deps = [":data_proto"], 9 | ) 10 | 11 | proto_library( 12 | name = "data_proto", 13 | srcs = ["data.proto"], 14 | deps = [ 15 | # Well known protos should be included as deps in the 16 | # proto_library rules of the source files importing them. 17 | # A list of all @com_google_protobuf well known protos can 18 | # seen with: 19 | # `bazel query 'kind(proto_library, @com_google_protobuf//:all)'` 20 | "@com_google_protobuf//:source_context_proto", 21 | ], 22 | ) 23 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | # Running the tests 2 | 3 | ## Install Bazel 4 | 5 | Running the tests requires [Bazel](https://bazel.build/), see 6 | [here](https://docs.bazel.build/versions/main/install.html) for installation 7 | instructions. 8 | 9 | ## Sample Commands 10 | 11 | **From any directory, run all tests found in the workspace:** 12 | ``` 13 | bazel test //src/... 14 | ``` 15 | 16 | **Run all tests in current directory** 17 | ``` 18 | # E.g. in directory `...test/java/com/google/devtools/cdbg/debuglets/java` 19 | bazel test :all 20 | ``` 21 | 22 | **Run individual test in current directory**: 23 | ``` 24 | # E.g. in directory `...test/java/com/google/devtools/cdbg/debuglets/java` 25 | bazel test :YamlConfigParserTest 26 | ``` 27 | -------------------------------------------------------------------------------- /src/agent/array_reader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_ARRAY_READER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_ARRAY_READER_H_ 19 | 20 | #include 21 | 22 | #include "common.h" 23 | #include "model_util.h" 24 | 25 | namespace devtools { 26 | namespace cdbg { 27 | 28 | class JVariant; 29 | struct FormatMessageModel; 30 | 31 | // Reads array element. 32 | class ArrayReader { 33 | public: 34 | virtual ~ArrayReader() { } 35 | 36 | // Reads "source[index]". In case of error sets "error_message". 37 | virtual ErrorOr ReadValue( 38 | const JVariant& source, 39 | const JVariant& index) const = 0; 40 | }; 41 | 42 | } // namespace cdbg 43 | } // namespace devtools 44 | 45 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_ARRAY_READER_H_ 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/agent/breakpoint_labels_provider.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_BREAKPOINT_LABELS_PROVIDER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_BREAKPOINT_LABELS_PROVIDER_H_ 19 | 20 | #include 21 | 22 | #include "common.h" 23 | 24 | namespace devtools { 25 | namespace cdbg { 26 | 27 | // Collects information about the local environment at the breakpoint 28 | // capture time. 29 | class BreakpointLabelsProvider { 30 | public: 31 | virtual ~BreakpointLabelsProvider() {} 32 | 33 | // Captures the environment information into set of breakpoint labels. This 34 | // function is called from the application thread, so it should complete as 35 | // quickly as possible. 36 | virtual void Collect() = 0; 37 | 38 | // Formats the breakpoint labels into breakpoint labels map. This function is 39 | // called from the debugger worker thread. 40 | virtual std::map Format() = 0; 41 | }; 42 | 43 | } // namespace cdbg 44 | } // namespace devtools 45 | 46 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_BREAKPOINT_LABELS_PROVIDER_H_ 47 | -------------------------------------------------------------------------------- /src/agent/cdbg_java_agent.lds: -------------------------------------------------------------------------------- 1 | VERS_1.0 { 2 | global: 3 | Agent_OnLoad; 4 | Agent_OnUnload; 5 | 6 | Java_com_google_devtools_cdbg_debuglets_java_AgentLogger_info; 7 | Java_com_google_devtools_cdbg_debuglets_java_AgentLogger_warn; 8 | Java_com_google_devtools_cdbg_debuglets_java_AgentLogger_severe; 9 | 10 | Java_com_google_devtools_cdbg_debuglets_java_GcpEnvironment_getAgentFlag; 11 | 12 | Java_com_google_devtools_cdbg_debuglets_java_Statistician_getStatistics; 13 | 14 | google_find_phdr; 15 | 16 | local: 17 | *; 18 | }; 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/agent/config_builder.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_CONFIG_BUILDER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_CONFIG_BUILDER_H_ 19 | 20 | #include "common.h" 21 | #include "config.h" 22 | 23 | namespace devtools { 24 | namespace cdbg { 25 | 26 | // Generates the default configuration. 27 | std::unique_ptr DefaultConfig(); 28 | 29 | } // namespace cdbg 30 | } // namespace devtools 31 | 32 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_CONFIG_BUILDER_H_ 33 | -------------------------------------------------------------------------------- /src/agent/debuggee_labels.cc: -------------------------------------------------------------------------------- 1 | #include "debuggee_labels.h" 2 | 3 | namespace devtools { 4 | namespace cdbg { 5 | 6 | constexpr char DebuggeeLabels::kBlocklistSourceLabel[]; 7 | constexpr char DebuggeeLabels::kBlocklistSourceDeprecatedFile[]; 8 | constexpr char DebuggeeLabels::kBlocklistSourceFile[]; 9 | constexpr char DebuggeeLabels::kBlocklistSourceNone[]; 10 | 11 | void DebuggeeLabels::Set(const std::string& name, const std::string& value) { 12 | labels_[name] = value; 13 | } 14 | 15 | JniLocalRef DebuggeeLabels::Get() const { 16 | ExceptionOr jni_labels = jniproxy::HashMap()->NewObject(); 17 | 18 | if (jni_labels.HasException()) { 19 | // This means an error occurred trying to allocate the HashMap in the JVM. 20 | return JniLocalRef(); 21 | } 22 | 23 | for (const auto& label : labels_) { 24 | auto rc = jniproxy::HashMap()->put(jni_labels.GetData().get(), 25 | JniToJavaString(label.first).get(), 26 | JniToJavaString(label.second).get()); 27 | 28 | if (rc.HasException()) { 29 | return JniLocalRef(); 30 | } 31 | } 32 | 33 | return jni_labels.Release(ExceptionAction::IGNORE); 34 | } 35 | 36 | 37 | } // namespace cdbg 38 | } // namespace devtools 39 | -------------------------------------------------------------------------------- /src/agent/debuggee_labels.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_DEBUGGEE_LABELS_H_ 2 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_DEBUGGEE_LABELS_H_ 3 | 4 | #include 5 | 6 | #include "jni_proxy_ju_hashmap.h" 7 | 8 | namespace devtools { 9 | namespace cdbg { 10 | 11 | // Utility class to hold labels to include in the registerDebuggee call that 12 | // goes to the HubClient on the Java side of the agent. This class will hold the 13 | // labels and then will handle generating the Java HashMap that can use used in 14 | // the registerDebuggee call. 15 | class DebuggeeLabels { 16 | public: 17 | DebuggeeLabels() = default; 18 | 19 | static constexpr char kBlocklistSourceLabel[] = "blocklistsource"; 20 | 21 | // Value for the BlocklistSource label which indicates the deprecated file 22 | // name and format was used for specifying the blocklist. 23 | static constexpr char kBlocklistSourceDeprecatedFile[] = "deprecatedfile"; 24 | 25 | // Value for the BlocklistSource label which indicates the new blocklist file 26 | // name and format was used for specifying the blocklist. 27 | static constexpr char kBlocklistSourceFile[] = "file"; 28 | 29 | // Value for the BlocklistSource label which indicates no blocklist was 30 | // specfified. 31 | static constexpr char kBlocklistSourceNone[] = "none"; 32 | 33 | void Set(const std::string& name, const std::string& value); 34 | 35 | JniLocalRef Get() const; 36 | 37 | private: 38 | std::map labels_; 39 | }; 40 | 41 | } // namespace cdbg 42 | } // namespace devtools 43 | 44 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_DEBUGGEE_LABELS_H_ 45 | -------------------------------------------------------------------------------- /src/agent/dynamic_logger.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_DYNAMIC_LOGGER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_DYNAMIC_LOGGER_H_ 19 | 20 | #include "common.h" 21 | #include "model.h" 22 | 23 | namespace devtools { 24 | namespace cdbg { 25 | 26 | struct ResolvedSourceLocation; 27 | 28 | // Writes dynamic log entries to application log. 29 | class DynamicLogger { 30 | public: 31 | virtual ~DynamicLogger() { } 32 | 33 | // Returns true if dynamic logger initialization has been completed 34 | // successfully. 35 | virtual bool IsAvailable() const = 0; 36 | 37 | // Synchronously writes a log entry to application log. Ignores any failures. 38 | virtual void Log(BreakpointModel::LogLevel level, 39 | const ResolvedSourceLocation& source_location, 40 | const std::string& message) = 0; 41 | }; 42 | 43 | } // namespace cdbg 44 | } // namespace devtools 45 | 46 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_DYNAMIC_LOGGER_H_ 47 | -------------------------------------------------------------------------------- /src/agent/encoding_util.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_ENCODING_UTIL_H_ 2 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_ENCODING_UTIL_H_ 3 | 4 | #include "common.h" 5 | 6 | namespace devtools { 7 | namespace cdbg { 8 | 9 | // Encodes buffer into a base 64 string. 10 | std::string Base64Encode(const char* in, size_t in_size); 11 | 12 | // Checks whether a buffer is valid utf8. The return value is the number of 13 | // valid utf8 bytes read from the beginning of the buffer. 14 | int ValidateUtf8(const char* in, size_t in_size); 15 | 16 | } // namespace cdbg 17 | } // namespace devtools 18 | 19 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_ENCODING_UTIL_H_ 20 | -------------------------------------------------------------------------------- /src/agent/generic_type_evaluator.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_GENERIC_TYPE_EVALUATOR_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_GENERIC_TYPE_EVALUATOR_H_ 19 | 20 | #include "common.h" 21 | #include "type_evaluator.h" 22 | 23 | namespace devtools { 24 | namespace cdbg { 25 | 26 | class ClassMetadataReader; 27 | struct NamedJVariant; 28 | 29 | // Captures all the fields of a Java object. 30 | class GenericTypeEvaluator : public TypeEvaluator { 31 | public: 32 | GenericTypeEvaluator() { } 33 | 34 | std::string GetEvaluatorName() override { return "GenericTypeEvaluator"; } 35 | 36 | void Evaluate( 37 | MethodCaller* method_caller, 38 | const ClassMetadataReader::Entry& class_metadata, 39 | jobject obj, 40 | bool is_watch_expression, 41 | std::vector* members) override; 42 | 43 | private: 44 | DISALLOW_COPY_AND_ASSIGN(GenericTypeEvaluator); 45 | }; 46 | 47 | } // namespace cdbg 48 | } // namespace devtools 49 | 50 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_GENERIC_TYPE_EVALUATOR_H_ 51 | 52 | -------------------------------------------------------------------------------- /src/agent/internals-class-loader/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | com.google.devtools.cdbg.debuglets.java 7 | cdbg_internals_class_loader 8 | SNAPSHOT 9 | 10 | 11 | 12 | 13 | 14 | target 15 | 16 | 17 | 18 | maven-compiler-plugin 19 | 3.0 20 | 21 | 1.7 22 | 1.7 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/agent/internals-class-loader/src/main/java/com/google/devtools/cdbg/debuglets/java/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | java_library( 4 | name = "classloader", 5 | srcs = ["InternalsClassLoader.java"], 6 | ) 7 | 8 | # Extract InternalsClassLoader.class from the :classloader .jar file. The .class 9 | # file is actually used by the debuglet. The debuglet needs ".class" file 10 | # rather than ".jar" file since that's the only thing JNI supports directly. 11 | genrule( 12 | name = "classloader_extract", 13 | srcs = [":classloader"], 14 | outs = ["cdbg_java_agent_internals_loader.class"], 15 | cmd = "$(JAVABASE)/bin/jar xf $(SRCS) com/google/devtools/cdbg/debuglets/java/InternalsClassLoader.class && " + 16 | "mv com/google/devtools/cdbg/debuglets/java/InternalsClassLoader.class $@ &&" + 17 | "rm -r com", 18 | toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"], 19 | ) 20 | -------------------------------------------------------------------------------- /src/agent/internals-class-loader/src/test/java/com/google/devtools/cdbg/debuglets/java/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_java//java:defs.bzl", "java_test") 16 | 17 | package(default_visibility = ["//visibility:public"]) 18 | 19 | java_test( 20 | name = "InternalsClassLoaderTest", 21 | size = "medium", 22 | srcs = [ 23 | "InternalsClassLoaderTest.java", 24 | ], 25 | deps = [ 26 | "//src/agent/internals/src/test/java/com/google/devtools/cdbg/debuglets/java:test_data_path", 27 | "//src/agent/internals-class-loader/src/main/java/com/google/devtools/cdbg/debuglets/java:classloader", 28 | "@maven//:junit_junit", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/DataTypeConverter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2022 Google Inc. All Rights Reserved. 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.devtools.cdbg.debuglets.java; 15 | 16 | /** 17 | * Utility class providing data conversions. 18 | */ 19 | class DataTypeConverter { 20 | private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray(); 21 | 22 | /** Converts the provided byte array into a hex string. */ 23 | public static String printHexBinary(byte[] data) { 24 | char[] hex = new char[data.length * 2]; 25 | for (int i = 0, j = 0; i < data.length; i++) { 26 | byte b = data[i]; 27 | hex[j++] = HEX_DIGITS[(b >> 4) & 0xf]; 28 | hex[j++] = HEX_DIGITS[b & 0xf]; 29 | } 30 | return new String(hex); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/DynamicLogHelper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.devtools.cdbg.debuglets.java; 15 | 16 | import java.util.logging.Level; 17 | import java.util.logging.Logger; 18 | 19 | /** 20 | * Helper class to use java.util.logging. 21 | * 22 | *

The main reason this class exists is that native code can't call {@link 23 | * Logger#getLogger(String)}. The call just fails with {@link NullPointerException} because the 24 | * caller class is not defined. 25 | */ 26 | final class DynamicLogHelper { 27 | private static final String CLOUD_DEBUGGER_LOGGER_NAME = "com.google.DynamicLog"; 28 | 29 | public static Logger getLogger() { 30 | return Logger.getLogger(CLOUD_DEBUGGER_LOGGER_NAME); 31 | } 32 | 33 | public static Level getInfoLevel() { 34 | return Level.INFO; 35 | } 36 | 37 | public static Level getWarningLevel() { 38 | return Level.WARNING; 39 | } 40 | 41 | public static Level getSevereLevel() { 42 | return Level.SEVERE; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/FormatMessage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.devtools.cdbg.debuglets.java; 15 | 16 | /** Custom data structure corresponding to FormatMessage proto. */ 17 | final class FormatMessage { 18 | private final String format; 19 | private final String[] parameters; 20 | 21 | public FormatMessage(String format, String... parameters) { 22 | this.format = format; 23 | this.parameters = parameters; 24 | } 25 | 26 | public String getFormat() { 27 | return format; 28 | } 29 | 30 | public String[] getParameters() { 31 | return parameters; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/GcpBreakpointLabelsProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.devtools.cdbg.debuglets.java; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | /** Collects information about the local environment at the breakpoint capture time. */ 20 | class GcpBreakpointLabelsProvider implements BreakpointLabelsProvider { 21 | @Override 22 | public String[] format() { 23 | List labels = new ArrayList<>(); 24 | 25 | // agentversion=MAJOR.MINOR 26 | labels.add("agentversion"); 27 | labels.add(GcpDebugletVersion.VERSION); 28 | 29 | return labels.toArray(new String[0]); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/Labels.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | /** Defines the keys for the well known labels used by the cloud debugger. */ 16 | package com.google.devtools.cdbg.debuglets.java; 17 | 18 | /** Autogenerated high-level data structure for cloud debugger labels */ 19 | public final class Labels { 20 | /** Autogenerated labels for message Breakpoint */ 21 | public static final class Breakpoint { 22 | 23 | public static final String REQUEST_LOG_ID = "requestlogid"; 24 | 25 | private Breakpoint() {} 26 | } 27 | 28 | /** Autogenerated labels for message Debuggee */ 29 | public static final class Debuggee { 30 | 31 | public static final String DOMAIN = "domain"; 32 | public static final String PROJECT_ID = "projectid"; 33 | public static final String MODULE = "module"; 34 | public static final String VERSION = "version"; 35 | public static final String MINOR_VERSION = "minorversion"; 36 | 37 | private Debuggee() {} 38 | } 39 | 40 | private Labels() {} 41 | } 42 | -------------------------------------------------------------------------------- /src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/Messages.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.devtools.cdbg.debuglets.java; 15 | 16 | final class Messages { 17 | public static final String UNDEFINED_BREAKPOINT_LOCATION = "Snapshot location not defined"; 18 | 19 | public static final String UNSUPPORTED_SOURCE_FILE_EXTENSION = "Unsupported file extension"; 20 | 21 | public static final String SOURCE_FILE_NOT_FOUND_IN_EXECUTABLE = 22 | "File was not found in the executable"; 23 | 24 | public static final String INVALID_LINE_NUMBER = "Invalid line number $0"; 25 | 26 | public static final String NO_CODE_FOUND_AT_LINE = "No code found at line $0"; 27 | 28 | public static final String BREAKPOINT_INSIDE_UNSAFE_CLASS = 29 | "Enclosing class contains unsafe Java code"; 30 | } 31 | -------------------------------------------------------------------------------- /src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/MetadataQuery.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.devtools.cdbg.debuglets.java; 15 | 16 | import com.google.auth.oauth2.GoogleCredentials; 17 | 18 | /** 19 | * Obtains GCP project details and auth token for backend calls. 20 | * 21 | *

This interface is thread safe. All functions return empty strings in case of a failure. 22 | * Querying metadata service is a local operation that doesn't involve network traffic, so it is not 23 | * supposed to fail under normal circumstances. 24 | */ 25 | interface MetadataQuery { 26 | /** Reads unique Google Cloud project ID (e.g. "cdbg-test-hub"). */ 27 | String getProjectId(); 28 | 29 | /** Reads unique numeric project ID (e.g. 901565030211). */ 30 | String getProjectNumber(); 31 | 32 | /** Retrieves the Google credentials. */ 33 | GoogleCredentials getGoogleCredential(); 34 | 35 | /** Retrieves OAuth access token for account authentication. */ 36 | String getAccessToken(); 37 | 38 | /** Closes HTTP connections and blocks any further calls. */ 39 | void shutdown(); 40 | } 41 | -------------------------------------------------------------------------------- /src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/ProxyObjectBase.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.devtools.cdbg.debuglets.java; 15 | 16 | /** Base class for all safe classes generated by {@link SafeCallerClassLoader}. */ 17 | public abstract class ProxyObjectBase { 18 | private final Object getRealObject() { return null; } 19 | private final void setRealObject(Object realObject) {} 20 | } 21 | -------------------------------------------------------------------------------- /src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/UserIdProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.devtools.cdbg.debuglets.java; 15 | 16 | /** 17 | * Collects information about the identity of the end user at the breakpoint capture time. 18 | * 19 | *

The class implementing this interface MUST collect the actual data in constructor, called by 20 | * the thread hitting the breakpoint. The captured data is then formatted later when {@link 21 | * UserIdProvider#format} is called on another thread. A new instance of this class will be created 22 | * for each breakpoint. 23 | */ 24 | interface UserIdProvider { 25 | /** 26 | * Formats the end user identity data collected at constructor. 27 | * 28 | *

This function is called from debugger worker thread. 29 | * 30 | * @return a pair where the first entry is the kind of identity (e.g., GAIA id) and the second 31 | * entry is the actual identity data (e.g., user name), or null if end user id was not 32 | * captured. 33 | */ 34 | String[] format(); 35 | } 36 | -------------------------------------------------------------------------------- /src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/YamlConfigParserException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.devtools.cdbg.debuglets.java; 15 | 16 | /** Exception that is thrown by YamlConfigParser. */ 17 | class YamlConfigParserException extends Exception { 18 | public YamlConfigParserException(String message) { 19 | super(message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/agent/internals/src/test/java/com/google/devtools/cdbg/debuglets/java/DynamicJarClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.myorg.myprod.test; 18 | 19 | import static org.junit.Assert.fail; 20 | 21 | public class DynamicJarClass { 22 | static { 23 | fail("DynamicJarClass is not supposed to get initialized"); 24 | } 25 | 26 | public DynamicJarClass() { 27 | fail("DynamicJarClass is not supposed to be used"); /* BPTAG: DYNAMIC_JAR_CLASS_CONSTRUCTOR */ 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/agent/jni_flags.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "common.h" 18 | #include "jni_utils.h" 19 | 20 | using google::GetCommandLineOption; 21 | 22 | /* 23 | * Class: com.google.devtools.cdbg.debuglets.java.GcpEnvironment 24 | * Method: getAgentFlag 25 | * Signature: (Ljava/lang/String;)Ljava/lang/String; 26 | */ 27 | extern "C" JNIEXPORT jobject JNICALL 28 | Java_com_google_devtools_cdbg_debuglets_java_GcpEnvironment_getAgentFlag( 29 | JNIEnv* jni, 30 | jclass cls, 31 | jstring flag) { 32 | devtools::cdbg::set_thread_jni(jni); 33 | 34 | std::string name = devtools::cdbg::JniToNativeString(flag); 35 | std::string value; 36 | if (!GetCommandLineOption(name.c_str(), &value)) { 37 | LOG(WARNING) << "Flag " << name << " not found"; 38 | return nullptr; // Flag not found. 39 | } 40 | 41 | return devtools::cdbg::JniToJavaString(value).release(); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/agent/jsoncpp_util.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_JSONCPP_UTIL_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_JSONCPP_UTIL_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include "common.h" 24 | #include "json/json.h" 25 | 26 | namespace devtools { 27 | namespace cdbg { 28 | 29 | // Gets the value of JSON string element. Returns empty string if the attribute 30 | // does not exist or if it is not a string type. 31 | std::string JsonCppGetString(const Json::Value& value, const char* name); 32 | 33 | // Gets the value of JSON boolean element. Returns "def" if the attribute 34 | // does not exist or if it is not a boolean type. 35 | bool JsonCppGetBool(const Json::Value& value, const char* name, bool def); 36 | 37 | // Gets the value of JSON integer element. Returns "def" if the attribute 38 | // does not exist or if it is not an integer type. 39 | int32_t JsonCppGetInt(const Json::Value& value, const char* name, int def); 40 | 41 | } // namespace cdbg 42 | } // namespace devtools 43 | 44 | 45 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_JSONCPP_UTIL_H_ 46 | -------------------------------------------------------------------------------- /src/agent/jvmti_buffer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_JVMTI_BUFFER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_JVMTI_BUFFER_H_ 19 | 20 | #include "common.h" 21 | 22 | namespace devtools { 23 | namespace cdbg { 24 | 25 | // Smart pointer class to automatically release JVMTI buffer when the 26 | // execution leaves the current scope. 27 | template 28 | class JvmtiBuffer { 29 | public: 30 | JvmtiBuffer() : ptr_(nullptr) { } 31 | 32 | ~JvmtiBuffer() { 33 | if (ptr_ != nullptr) { 34 | jvmti()->Deallocate(reinterpret_cast(ptr_)); 35 | } 36 | } 37 | 38 | const T* get() const { return ptr_; } 39 | 40 | T** ref() { 41 | DCHECK(ptr_ == nullptr); // Uninitialized buffer expected 42 | return &ptr_; 43 | } 44 | 45 | private: 46 | // Pointer to JVMTI allocated memory or nullptr. 47 | T* ptr_; 48 | 49 | DISALLOW_COPY_AND_ASSIGN(JvmtiBuffer); 50 | }; 51 | 52 | } // namespace cdbg 53 | } // namespace devtools 54 | 55 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_JVMTI_BUFFER_H_ 56 | 57 | -------------------------------------------------------------------------------- /src/agent/legacy_flags.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "common.h" 18 | 19 | // 20 | // Define flags we no longer use. We can't remove these flags because some 21 | // applications still use them and the agent will fail to load if it the 22 | // command line includes an unrecognized flag. 23 | // 24 | 25 | // Deprecated as of 11/2015. 26 | ABSL_FLAG(string, cdbg_agentdir, "", "deprecated"); 27 | -------------------------------------------------------------------------------- /src/agent/scheduler.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "scheduler.h" 18 | 19 | namespace devtools { 20 | namespace cdbg { 21 | 22 | static Scheduler<>::Id NullId __attribute__((unused)) = { 0, -1 }; 23 | 24 | } // namespace cdbg 25 | } // namespace devtools 26 | -------------------------------------------------------------------------------- /src/agent/service-account-auth/src/main/java/com/google/devtools/cdbg/ServiceAccountAuthTool.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.devtools.cdbg.debuglets.java; 15 | 16 | /** 17 | * Command line utility to print OAuth access token exchanged for service account p12 private key. 18 | * 19 | *

Syntax: ServiceAccountAuthTool 20 | */ 21 | public final class ServiceAccountAuthTool { 22 | public static void main(String[] args) throws Exception { 23 | if (args.length != 1) { 24 | throw new IllegalArgumentException("Require JSON file as argument"); 25 | } 26 | 27 | String jsonFile = args[0]; 28 | ServiceAccountAuth auth = new ServiceAccountAuth(jsonFile); 29 | System.out.println(auth.getAccessToken()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/agent/user_id_provider.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_USER_ID_PROVIDER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_USER_ID_PROVIDER_H_ 19 | 20 | #include 21 | 22 | #include "common.h" 23 | 24 | namespace devtools { 25 | namespace cdbg { 26 | 27 | // Collects information about the end user id at the breakpoint capture time. 28 | class UserIdProvider { 29 | public: 30 | virtual ~UserIdProvider() {} 31 | 32 | // Captures the identity of the end user. This function is called from the 33 | // application thread, so it should complete as quickly as possible. 34 | virtual void Collect() = 0; 35 | 36 | // Populates user identity in kind and id. Returns false if user id cannot be 37 | // read. 38 | virtual bool Format(std::string* kind, std::string* id) = 0; 39 | }; 40 | 41 | } // namespace cdbg 42 | } // namespace devtools 43 | 44 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_USER_ID_PROVIDER_H_ 45 | -------------------------------------------------------------------------------- /src/agent/yaml_data_visibility_config_reader.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_YAML_DATA_VISIBILITY_CONFIG_READER_H_ 2 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_YAML_DATA_VISIBILITY_CONFIG_READER_H_ 3 | 4 | #include "class_path_lookup.h" 5 | #include "common.h" 6 | #include "glob_data_visibility_policy.h" 7 | 8 | namespace devtools { 9 | namespace cdbg { 10 | 11 | // Loads .yaml visibility configuration. 12 | GlobDataVisibilityPolicy::Config ReadYamlDataVisibilityConfiguration( 13 | ClassPathLookup* class_path_lookup, std::string* yaml_source); 14 | 15 | } // namespace cdbg 16 | } // namespace devtools 17 | 18 | 19 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_YAML_DATA_VISIBILITY_CONFIG_READER_H_ 20 | -------------------------------------------------------------------------------- /src/codegen/config-test.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": [ 3 | { 4 | "className": "java.net.URL", 5 | "methods": [ 6 | { 7 | "methodName": "", 8 | "methodSignature": "(Ljava/lang/String;)V" 9 | } 10 | ], 11 | "nativeNamespace": "jniproxy" 12 | }, 13 | { 14 | "className": "java.net.URLClassLoader", 15 | "methods": [ 16 | { 17 | "methodName": "", 18 | "methodSignature": "([Ljava/net/URL;)V" 19 | } 20 | ], 21 | "nativeNamespace": "jniproxy" 22 | }, 23 | { 24 | "className": "com.google.devtools.cdbg.debuglets.java.ClassFileTextifier", 25 | "methods": [ 26 | { 27 | "methodName": "textify" 28 | } 29 | ], 30 | "nativeNamespace": "jniproxy" 31 | }, 32 | { 33 | "className": "jasmin.Main", 34 | "methods": [ 35 | { 36 | "methodName": "assemble" 37 | } 38 | ], 39 | "nativeNamespace": "jniproxy::jasmin" 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /src/codegen/src/main/java/devtools/cdbg/debuglets/java/codegen/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | java_library( 4 | name = "jni_proxy_code_gen_lib", 5 | srcs = [ 6 | "Config.java", 7 | "JniProxyCodeGen.java", 8 | ], 9 | resources = glob(["*.tpl"]), 10 | deps = [ 11 | "@maven//:com_google_guava_guava", 12 | "@maven//:org_ow2_asm_asm", 13 | "@maven//:org_freemarker_freemarker", 14 | "@maven//:com_google_code_gson_gson", 15 | ], 16 | ) 17 | 18 | java_binary( 19 | name = "jni_proxy_code_gen_tool", 20 | main_class = "devtools.cdbg.debuglets.java.codegen.JniProxyCodeGen", 21 | runtime_deps = [ 22 | ":jni_proxy_code_gen_lib", 23 | "//src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java:agent", 24 | ], 25 | ) 26 | 27 | java_binary( 28 | name = "jni_test_proxy_code_gen_tool", 29 | testonly = 1, 30 | main_class = "devtools.cdbg.debuglets.java.codegen.JniProxyCodeGen", 31 | runtime_deps = [ 32 | ":jni_proxy_code_gen_lib", 33 | "//src/agent/internals/src/test/java/com/google/devtools/cdbg/debuglets/java:class_file_textifier", 34 | "@jasmin//jar", 35 | ], 36 | ) 37 | -------------------------------------------------------------------------------- /tests/agent/build_defs.bzl: -------------------------------------------------------------------------------- 1 | def jvm_test(name, srcs, copts, cc_deps, java_deps): 2 | native.cc_binary( 3 | name = "lib%s.so" % name, 4 | testonly = 1, 5 | srcs = srcs, 6 | copts = copts, 7 | linkshared = 1, 8 | linkstatic = 1, 9 | deps = [ 10 | "//tests/agent:jvm_test_base", 11 | ] + cc_deps, 12 | ) 13 | 14 | native.genrule( 15 | name = name + "_main", 16 | outs = [name + ".java"], 17 | cmd = """ 18 | echo "final class JvmTestMain {" > $@ 19 | echo " static {" >> $@ 20 | echo " System.loadLibrary(\\"%s\\");" >> $@ 21 | echo " }" >> $@ 22 | echo "" >> $@ 23 | echo " static native void run();" >> $@ 24 | echo "}" >> $@ 25 | echo "" >> $@ 26 | echo "public final class %s {" >> $@ 27 | echo " public static void main(String[] args) {" >> $@ 28 | echo " JvmTestMain.run();" >> $@ 29 | echo " }" >> $@ 30 | echo "}" >> $@ 31 | """ % (name, name), 32 | ) 33 | 34 | native.java_test( 35 | name = name, 36 | testonly = 1, 37 | srcs = [name + ".java"], 38 | main_class = name, 39 | resources = [ 40 | ":lib%s.so" % name, 41 | ], 42 | deps = [ 43 | ":lib%s.so" % name, 44 | ], 45 | use_testrunner = 0, 46 | runtime_deps = java_deps, 47 | ) 48 | -------------------------------------------------------------------------------- /tests/agent/jasmin_utils.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_JASMIN_UTILS_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_JASMIN_UTILS_H_ 19 | 20 | #include "src/agent/common.h" 21 | 22 | namespace devtools { 23 | namespace cdbg { 24 | 25 | // 26 | // C++ wrapper for Jasmin assembler. Jasmin is an assembly for JVM. 27 | // For more details see: http://jasmin.sourceforge.net/ 28 | // 29 | 30 | // Builds Java class from assembly using Jasmin. 31 | std::string Assemble(const std::string& asm_code); 32 | 33 | // Assembles test Java class that only has a single method using Jasmin. We 34 | // never set method arguments, since NanoJava interpreter ignores it anyway. 35 | std::string AssembleMethod(const std::string& return_type, 36 | const std::string& method_asm_code); 37 | 38 | } // namespace cdbg 39 | } // namespace devtools 40 | 41 | 42 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_JASMIN_UTILS_H_ 43 | -------------------------------------------------------------------------------- /tests/agent/mock_array_reader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_ARRAY_READER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_ARRAY_READER_H_ 19 | 20 | #include "gmock/gmock.h" 21 | #include "src/agent/array_reader.h" 22 | 23 | namespace devtools { 24 | namespace cdbg { 25 | 26 | class MockArrayReader : public ArrayReader { 27 | public: 28 | MOCK_METHOD(ErrorOr, ReadValue, (const JVariant&, const JVariant&), 29 | (const, override)); 30 | }; 31 | 32 | } // namespace cdbg 33 | } // namespace devtools 34 | 35 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_ARRAY_READER_H_ 36 | -------------------------------------------------------------------------------- /tests/agent/mock_breakpoint_labels_provider.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_BREAKPOINT_LABELS_PROVIDER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_BREAKPOINT_LABELS_PROVIDER_H_ 19 | 20 | #include "gmock/gmock.h" 21 | 22 | #include "src/agent/breakpoint_labels_provider.h" 23 | #include "src/agent/class_indexer.h" 24 | 25 | namespace devtools { 26 | namespace cdbg { 27 | 28 | class MockBreakpointLabelsProvider : public BreakpointLabelsProvider { 29 | public: 30 | MOCK_METHOD(void, Collect, (), (override)); 31 | 32 | MOCK_METHOD((std::map), Format, (), (override)); 33 | }; 34 | 35 | } // namespace cdbg 36 | } // namespace devtools 37 | 38 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_BREAKPOINT_LABELS_PROVIDER_H_ 39 | -------------------------------------------------------------------------------- /tests/agent/mock_class_metadata_reader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_CLASS_METADATA_READER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_CLASS_METADATA_READER_H_ 19 | 20 | #include "gmock/gmock.h" 21 | #include "src/agent/class_metadata_reader.h" 22 | 23 | namespace devtools { 24 | namespace cdbg { 25 | 26 | class MockClassMetadataReader : public ClassMetadataReader { 27 | public: 28 | MOCK_METHOD(const Entry&, GetClassMetadata, (jclass cls), (override)); 29 | }; 30 | 31 | 32 | } // namespace cdbg 33 | } // namespace devtools 34 | 35 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_CLASS_METADATA_READER_H_ 36 | 37 | -------------------------------------------------------------------------------- /tests/agent/mock_dynamic_logger.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_DYNAMIC_LOGGER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_DYNAMIC_LOGGER_H_ 19 | 20 | #include "gmock/gmock.h" 21 | #include "src/agent/dynamic_logger.h" 22 | #include "src/agent/resolved_source_location.h" 23 | 24 | namespace devtools { 25 | namespace cdbg { 26 | 27 | class MockDynamicLogger : public DynamicLogger { 28 | public: 29 | MockDynamicLogger() { 30 | ON_CALL(*this, IsAvailable()) 31 | .WillByDefault(testing::Return(true)); 32 | } 33 | 34 | MOCK_METHOD(bool, IsAvailable, (), (const, override)); 35 | 36 | MOCK_METHOD(void, Log, 37 | (BreakpointModel::LogLevel, const ResolvedSourceLocation&, 38 | const std::string&), 39 | (override)); 40 | }; 41 | 42 | } // namespace cdbg 43 | } // namespace devtools 44 | 45 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_DYNAMIC_LOGGER_H_ 46 | -------------------------------------------------------------------------------- /tests/agent/mock_nanojava_internal_error_provider.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_NANOJAVA_INTERNAL_ERROR_PROVIDER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_NANOJAVA_INTERNAL_ERROR_PROVIDER_H_ 19 | 20 | #include "gmock/gmock.h" 21 | #include "src/agent/nanojava_internal_error_builder.h" 22 | 23 | namespace devtools { 24 | namespace cdbg { 25 | namespace nanojava { 26 | 27 | class MockNanoJavaInternalErrorProvider 28 | : public NanoJavaInternalErrorProvider { 29 | public: 30 | MOCK_METHOD(std::string, method_name, (), (const, override)); 31 | 32 | MOCK_METHOD(std::string, FormatCallStack, (), (const, override)); 33 | 34 | MOCK_METHOD(void, SetResult, (MethodCallResult), (override)); 35 | }; 36 | 37 | } // namespace nanojava 38 | } // namespace cdbg 39 | } // namespace devtools 40 | 41 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_NANOJAVA_INTERNAL_ERROR_PROVIDER_H_ 42 | -------------------------------------------------------------------------------- /tests/agent/mock_object_evaluator.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_OBJECT_EVALUATOR_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_OBJECT_EVALUATOR_H_ 19 | 20 | #include "gmock/gmock.h" 21 | #include "src/agent/object_evaluator.h" 22 | 23 | namespace devtools { 24 | namespace cdbg { 25 | 26 | class MockObjectEvaluator : public ObjectEvaluator { 27 | public: 28 | MOCK_METHOD(void, Evaluate, 29 | (MethodCaller*, jobject, bool, std::vector*), 30 | (override)); 31 | }; 32 | 33 | } // namespace cdbg 34 | } // namespace devtools 35 | 36 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_OBJECT_EVALUATOR_H_ 37 | -------------------------------------------------------------------------------- /tests/agent/mock_user_id_provider.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_USER_ID_PROVIDER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_USER_ID_PROVIDER_H_ 19 | 20 | #include "gmock/gmock.h" 21 | #include "src/agent/user_id_provider.h" 22 | 23 | namespace devtools { 24 | namespace cdbg { 25 | 26 | class MockUserIdProvider : public UserIdProvider { 27 | public: 28 | MOCK_METHOD(void, Collect, (), (override)); 29 | 30 | MOCK_METHOD(bool, Format, (std::string * kind, std::string* id), (override)); 31 | }; 32 | 33 | } // namespace cdbg 34 | } // namespace devtools 35 | 36 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_USER_ID_PROVIDER_H_ 37 | -------------------------------------------------------------------------------- /tests/agent/mock_worker_provider.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_WORKER_PROVIDER_H_ 18 | #define DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_WORKER_PROVIDER_H_ 19 | 20 | #include "gmock/gmock.h" 21 | #include "src/agent/model_json.h" 22 | #include "src/agent/worker.h" 23 | 24 | namespace devtools { 25 | namespace cdbg { 26 | 27 | class MockWorkerProvider : public Worker::Provider { 28 | public: 29 | MockWorkerProvider() { 30 | ON_CALL(*this, OnWorkerReady(::testing::_)) 31 | .WillByDefault(testing::Return(true)); 32 | } 33 | 34 | MOCK_METHOD(bool, OnWorkerReady, (DebuggeeLabels*), (override)); 35 | 36 | MOCK_METHOD(void, OnIdle, (), (override)); 37 | 38 | MOCK_METHOD(void, OnBreakpointsUpdated, 39 | (std::vector>), (override)); 40 | 41 | MOCK_METHOD(void, EnableDebugger, (bool), (override)); 42 | }; 43 | 44 | } // namespace cdbg 45 | } // namespace devtools 46 | 47 | #endif // DEVTOOLS_CDBG_DEBUGLETS_JAVA_MOCK_WORKER_PROVIDER_H_ 48 | -------------------------------------------------------------------------------- /third_party/antlr/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | SOFTWARE RIGHTS 3 | 4 | ANTLR 1989-2006 Developed by Terence Parr 5 | Partially supported by University of San Francisco & jGuru.com 6 | 7 | We reserve no legal rights to the ANTLR--it is fully in the 8 | public domain. An individual or company may do whatever 9 | they wish with source code distributed with ANTLR or the 10 | code generated by ANTLR, including the incorporation of 11 | ANTLR, or its output, into commerical software. 12 | 13 | We encourage users to develop software with ANTLR. However, 14 | we do ask that credit is given to us for developing 15 | ANTLR. By "credit", we mean that if you use ANTLR or 16 | incorporate any source code into one of your programs 17 | (commercial product, research project, or otherwise) that 18 | you acknowledge this fact somewhere in the documentation, 19 | research report, etc... If you like ANTLR and have 20 | developed a nice tool with the output, please mention that 21 | you developed it using ANTLR. In addition, we ask that the 22 | headers remain intact in our source code. As long as these 23 | guidelines are kept, we expect to continue enhancing this 24 | system and expect to make other tools available as they are 25 | completed. 26 | 27 | The primary ANTLR guy: 28 | 29 | Terence Parr 30 | parrt@cs.usfca.edu 31 | parrt@antlr.org 32 | -------------------------------------------------------------------------------- /third_party/antlr/README.md: -------------------------------------------------------------------------------- 1 | ## Notes 2 | 3 | * Version 2.7.7 of antlr is used here. 4 | * Source: https://www.antlr2.org/download/antlr-2.7.7.tar.gz 5 | * Only the `antlr` and `lib/cpp` directories were kept. 6 | * Local file `antlr.patch` contains the changes made to the original source to 7 | allow the local builds to succeed. 8 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ANTLRError.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/ANTLRError.java#2 $ 8 | */ 9 | 10 | public class ANTLRError extends Error { 11 | 12 | /** 13 | * ANTLRError constructor comment. 14 | */ 15 | public ANTLRError() { 16 | super(); 17 | } 18 | 19 | /** 20 | * ANTLRError constructor comment. 21 | * @param s java.lang.String 22 | */ 23 | public ANTLRError(String s) { 24 | super(s); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ANTLRException.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/ANTLRException.java#2 $ 8 | */ 9 | 10 | public class ANTLRException extends Exception { 11 | 12 | public ANTLRException() { 13 | super(); 14 | } 15 | 16 | public ANTLRException(String s) { 17 | super(s); 18 | } 19 | 20 | public ANTLRException(String message, Throwable cause) { 21 | super(message, cause); 22 | } 23 | 24 | public ANTLRException(Throwable cause) { 25 | super(cause); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ANTLRTokdefParserTokenTypes.java: -------------------------------------------------------------------------------- 1 | // $ANTLR : "tokdef.g" -> "ANTLRTokdefParser.java"$ 2 | package antlr; 3 | public interface ANTLRTokdefParserTokenTypes { 4 | int EOF = 1; 5 | int NULL_TREE_LOOKAHEAD = 3; 6 | int ID = 4; 7 | int STRING = 5; 8 | int ASSIGN = 6; 9 | int LPAREN = 7; 10 | int RPAREN = 8; 11 | int INT = 9; 12 | int WS = 10; 13 | int SL_COMMENT = 11; 14 | int ML_COMMENT = 12; 15 | int ESC = 13; 16 | int DIGIT = 14; 17 | int XDIGIT = 15; 18 | } 19 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ASTPair.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/ASTPair.java#2 $ 8 | */ 9 | 10 | import antlr.collections.AST; 11 | 12 | /** ASTPair: utility class used for manipulating a pair of ASTs 13 | * representing the current AST root and current AST sibling. 14 | * This exists to compensate for the lack of pointers or 'var' 15 | * arguments in Java. 16 | */ 17 | public class ASTPair { 18 | public AST root; // current root of tree 19 | public AST child; // current child to which siblings are added 20 | 21 | /** Make sure that child is the last sibling */ 22 | public final void advanceChildToEnd() { 23 | if (child != null) { 24 | while (child.getNextSibling() != null) { 25 | child = child.getNextSibling(); 26 | } 27 | } 28 | } 29 | 30 | /** Copy an ASTPair. Don't call it clone() because we want type-safety */ 31 | public ASTPair copy() { 32 | ASTPair tmp = new ASTPair(); 33 | tmp.root = root; 34 | tmp.child = child; 35 | return tmp; 36 | } 37 | 38 | public String toString() { 39 | String r = root == null ? "null" : root.getText(); 40 | String c = child == null ? "null" : child.getText(); 41 | return "[" + r + "," + c + "]"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ASTVisitor.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/ASTVisitor.java#2 $ 8 | */ 9 | 10 | import antlr.collections.AST; 11 | 12 | public interface ASTVisitor { 13 | public void visit(AST node); 14 | } 15 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ASdebug/ASDebugStream.java: -------------------------------------------------------------------------------- 1 | package antlr.ASdebug; 2 | 3 | import antlr.Token; 4 | import antlr.TokenStream; 5 | 6 | /** 7 | * Default implementation of IASDebugStream methods. 8 | * @author Prashant Deva 9 | */ 10 | public final class ASDebugStream 11 | { 12 | 13 | public static String getEntireText(TokenStream stream) 14 | { 15 | if (stream instanceof IASDebugStream) 16 | { 17 | IASDebugStream dbgStream = (IASDebugStream) stream; 18 | return dbgStream.getEntireText(); 19 | } 20 | return null; 21 | } 22 | 23 | public static TokenOffsetInfo getOffsetInfo(TokenStream stream, Token token) 24 | { 25 | if (stream instanceof IASDebugStream) 26 | { 27 | IASDebugStream dbgStream = (IASDebugStream) stream; 28 | return dbgStream.getOffsetInfo(token); 29 | } 30 | return null; 31 | } 32 | 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ASdebug/IASDebugStream.java: -------------------------------------------------------------------------------- 1 | package antlr.ASdebug; 2 | 3 | import antlr.Token; 4 | 5 | /** 6 | * Provides information used by the 'Input Text' view 7 | * of Antlr Studio. 8 | * @author Prashant Deva 9 | */ 10 | public interface IASDebugStream 11 | { 12 | /** 13 | * Returns the entire text input to the lexer. 14 | * @return The entire text or null, if error occured or System.in was used. 15 | */ 16 | String getEntireText(); 17 | 18 | /** 19 | * Returns the offset information for the token 20 | * @param token the token whose information need to be retrieved 21 | * @return offset info, or null 22 | */ 23 | TokenOffsetInfo getOffsetInfo(Token token); 24 | } 25 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ASdebug/TokenOffsetInfo.java: -------------------------------------------------------------------------------- 1 | package antlr.ASdebug; 2 | 3 | /** 4 | * Provides offset info for a token.
5 | * All offsets are 0-based. 6 | * @author Prashant Deva 7 | */ 8 | public class TokenOffsetInfo 9 | { 10 | public final int beginOffset, length; 11 | 12 | public TokenOffsetInfo(int offset, int length) 13 | { 14 | this.beginOffset = offset; 15 | this.length = length; 16 | } 17 | 18 | public int getEndOffset() 19 | { 20 | return beginOffset+length-1; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ActionElement.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/ActionElement.java#2 $ 8 | */ 9 | 10 | class ActionElement extends AlternativeElement { 11 | protected String actionText; 12 | protected boolean isSemPred = false; 13 | 14 | 15 | public ActionElement(Grammar g, Token t) { 16 | super(g); 17 | actionText = t.getText(); 18 | line = t.getLine(); 19 | column = t.getColumn(); 20 | } 21 | 22 | public void generate() { 23 | grammar.generator.gen(this); 24 | } 25 | 26 | public Lookahead look(int k) { 27 | return grammar.theLLkAnalyzer.look(k, this); 28 | } 29 | 30 | public String toString() { 31 | return " " + actionText + (isSemPred?"?":""); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ActionTransInfo.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/ActionTransInfo.java#2 $ 8 | */ 9 | 10 | /** 11 | * This class contains information about how an action 12 | * was translated (using the AST conversion rules). 13 | */ 14 | public class ActionTransInfo { 15 | public boolean assignToRoot = false; // somebody did a "#rule = " 16 | public String refRuleRoot = null; // somebody referenced #rule; string is translated var 17 | public String followSetName = null; // somebody referenced $FOLLOW; string is the name of the lookahead set 18 | 19 | public String toString() { 20 | return "assignToRoot:" + assignToRoot + ", refRuleRoot:" 21 | + refRuleRoot + ", FOLLOW Set:" + followSetName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/AlternativeElement.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/AlternativeElement.java#2 $ 8 | */ 9 | 10 | abstract class AlternativeElement extends GrammarElement { 11 | AlternativeElement next; 12 | protected int autoGenType = AUTO_GEN_NONE; 13 | 14 | protected String enclosingRuleName; 15 | 16 | public AlternativeElement(Grammar g) { 17 | super(g); 18 | } 19 | 20 | public AlternativeElement(Grammar g, Token start) { 21 | super(g, start); 22 | } 23 | 24 | public AlternativeElement(Grammar g, Token start, int autoGenType_) { 25 | super(g, start); 26 | autoGenType = autoGenType_; 27 | } 28 | 29 | public int getAutoGenType() { 30 | return autoGenType; 31 | } 32 | 33 | public void setAutoGenType(int a) { 34 | autoGenType = a; 35 | } 36 | 37 | public String getLabel() { 38 | return null; 39 | } 40 | 41 | public void setLabel(String label) { 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/BlockContext.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/BlockContext.java#2 $ 8 | */ 9 | 10 | /**BlockContext stores the information needed when creating an 11 | * alternative (list of elements). Entering a subrule requires 12 | * that we save this state as each block of alternatives 13 | * requires state such as "tail of current alternative." 14 | */ 15 | class BlockContext { 16 | AlternativeBlock block; // current block of alternatives 17 | int altNum; // which alt are we accepting 0..n-1 18 | BlockEndElement blockEnd; // used if nested 19 | 20 | 21 | public void addAlternativeElement(AlternativeElement e) { 22 | currentAlt().addElement(e); 23 | } 24 | 25 | public Alternative currentAlt() { 26 | return (Alternative)block.alternatives.elementAt(altNum); 27 | } 28 | 29 | public AlternativeElement currentElement() { 30 | return currentAlt().tail; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/BlockEndElement.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/BlockEndElement.java#2 $ 8 | */ 9 | 10 | /**All alternative blocks are "terminated" by BlockEndElements unless 11 | * they are rule blocks (in which case they use RuleEndElement). 12 | */ 13 | class BlockEndElement extends AlternativeElement { 14 | protected boolean[] lock; // for analysis; used to avoid infinite loops 15 | protected AlternativeBlock block;// ending blocks know what block they terminate 16 | 17 | 18 | public BlockEndElement(Grammar g) { 19 | super(g); 20 | lock = new boolean[g.maxk + 1]; 21 | } 22 | 23 | public Lookahead look(int k) { 24 | return grammar.theLLkAnalyzer.look(k, this); 25 | } 26 | 27 | public String toString() { 28 | //return " [BlkEnd]"; 29 | return ""; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/BlockWithImpliedExitPath.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/BlockWithImpliedExitPath.java#2 $ 8 | */ 9 | 10 | abstract class BlockWithImpliedExitPath extends AlternativeBlock { 11 | protected int exitLookaheadDepth; // lookahead needed to handle optional path 12 | /** lookahead to bypass block; set 13 | * by deterministic(). 1..k of Lookahead 14 | */ 15 | protected Lookahead[] exitCache = new Lookahead[grammar.maxk + 1]; 16 | 17 | public BlockWithImpliedExitPath(Grammar g) { 18 | super(g); 19 | } 20 | 21 | public BlockWithImpliedExitPath(Grammar g, Token start) { 22 | super(g, start, false); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CSharpBlockFinishingInfo.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id:$ 8 | */ 9 | 10 | // 11 | // ANTLR C# Code Generator by Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com 12 | // 13 | 14 | class CSharpBlockFinishingInfo 15 | { 16 | String postscript; // what to generate to terminate block 17 | boolean generatedSwitch;// did block finish with "default:" of switch? 18 | boolean generatedAnIf; 19 | 20 | /** When generating an if or switch, end-of-token lookahead sets 21 | * will become the else or default clause, don't generate an 22 | * error clause in this case. 23 | */ 24 | boolean needAnErrorClause; 25 | 26 | 27 | public CSharpBlockFinishingInfo() 28 | { 29 | postscript=null; 30 | generatedSwitch=generatedSwitch = false; 31 | needAnErrorClause = true; 32 | } 33 | 34 | public CSharpBlockFinishingInfo(String ps, boolean genS, boolean generatedAnIf, boolean n) 35 | { 36 | postscript = ps; 37 | generatedSwitch = genS; 38 | this.generatedAnIf = generatedAnIf; 39 | needAnErrorClause = n; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CSharpNameSpace.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /** 4 | * ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.cs.usfca.edu 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * Container for a C++ namespace specification. Namespaces can be 9 | * nested, so this contains a vector of all the nested names. 10 | * 11 | * @author David Wagner (JPL/Caltech) 8-12-00 12 | * 13 | * $Id:$ 14 | */ 15 | 16 | 17 | // 18 | // ANTLR C# Code Generator by Micheal Jordan 19 | // Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com 20 | // Anthony Oguntimehin 21 | // 22 | // With many thanks to Eric V. Smith from the ANTLR list. 23 | // 24 | 25 | // HISTORY: 26 | // 27 | // 17-May-2002 kunle Original version 28 | // 29 | 30 | import java.util.Vector; 31 | import java.util.Enumeration; 32 | import java.io.PrintWriter; 33 | import java.util.StringTokenizer; 34 | 35 | public class CSharpNameSpace extends NameSpace 36 | { 37 | public CSharpNameSpace(String name) 38 | { 39 | super(name); 40 | } 41 | 42 | /** 43 | * Method to generate the required CSharp namespace declarations 44 | */ 45 | void emitDeclarations(PrintWriter out) { 46 | out.println("namespace " + getName() ); 47 | out.println("{"); 48 | } 49 | 50 | /** 51 | * Method to generate the required CSharp namespace closures 52 | */ 53 | void emitClosures(PrintWriter out) { 54 | out.println("}"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CharFormatter.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/CharFormatter.java#2 $ 8 | */ 9 | 10 | /** Interface used by BitSet to format elements of the set when 11 | * converting to string 12 | */ 13 | public interface CharFormatter { 14 | 15 | 16 | public String escapeChar(int c, boolean forCharLiteral); 17 | 18 | public String escapeString(String s); 19 | 20 | public String literalChar(int c); 21 | 22 | public String literalString(String s); 23 | } 24 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CharLiteralElement.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/CharLiteralElement.java#2 $ 8 | */ 9 | 10 | class CharLiteralElement extends GrammarAtom { 11 | 12 | 13 | public CharLiteralElement(LexerGrammar g, Token t, boolean inverted, int autoGenType) { 14 | super(g, t, AUTO_GEN_NONE); 15 | tokenType = ANTLRLexer.tokenTypeForCharLiteral(t.getText()); 16 | g.charVocabulary.add(tokenType); 17 | line = t.getLine(); 18 | not = inverted; 19 | this.autoGenType = autoGenType; 20 | } 21 | 22 | public void generate() { 23 | grammar.generator.gen(this); 24 | } 25 | 26 | public Lookahead look(int k) { 27 | return grammar.theLLkAnalyzer.look(k, this); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CharRangeElement.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/CharRangeElement.java#2 $ 8 | */ 9 | 10 | class CharRangeElement extends AlternativeElement { 11 | String label; 12 | protected char begin = 0; 13 | protected char end = 0; 14 | protected String beginText; 15 | protected String endText; 16 | 17 | 18 | public CharRangeElement(LexerGrammar g, Token t1, Token t2, int autoGenType) { 19 | super(g); 20 | begin = (char)ANTLRLexer.tokenTypeForCharLiteral(t1.getText()); 21 | beginText = t1.getText(); 22 | end = (char)ANTLRLexer.tokenTypeForCharLiteral(t2.getText()); 23 | endText = t2.getText(); 24 | line = t1.getLine(); 25 | // track which characters are referenced in the grammar 26 | for (int i = begin; i <= end; i++) { 27 | g.charVocabulary.add(i); 28 | } 29 | this.autoGenType = autoGenType; 30 | } 31 | 32 | public void generate() { 33 | grammar.generator.gen(this); 34 | } 35 | 36 | public String getLabel() { 37 | return label; 38 | } 39 | 40 | public Lookahead look(int k) { 41 | return grammar.theLLkAnalyzer.look(k, this); 42 | } 43 | 44 | public void setLabel(String label_) { 45 | label = label_; 46 | } 47 | 48 | public String toString() { 49 | if (label != null) 50 | return " " + label + ":" + beginText + ".." + endText; 51 | else 52 | return " " + beginText + ".." + endText; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CharStreamException.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/CharStreamException.java#2 $ 8 | */ 9 | 10 | /** 11 | * Anything that goes wrong while generating a stream of characters 12 | */ 13 | public class CharStreamException extends ANTLRException { 14 | /** 15 | * CharStreamException constructor comment. 16 | * @param s java.lang.String 17 | */ 18 | public CharStreamException(String s) { 19 | super(s); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CharStreamIOException.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/CharStreamIOException.java#2 $ 8 | */ 9 | 10 | import java.io.IOException; 11 | 12 | /** 13 | * Wrap an IOException in a CharStreamException 14 | */ 15 | public class CharStreamIOException extends CharStreamException { 16 | public IOException io; 17 | 18 | public CharStreamIOException(IOException io) { 19 | super(io.getMessage()); 20 | this.io = io; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CommonAST.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/CommonAST.java#2 $ 8 | */ 9 | 10 | import antlr.collections.AST; 11 | 12 | /** Common AST node implementation */ 13 | public class CommonAST extends BaseAST { 14 | int ttype = Token.INVALID_TYPE; 15 | String text; 16 | 17 | 18 | /** Get the token text for this node */ 19 | public String getText() { 20 | return text; 21 | } 22 | 23 | /** Get the token type for this node */ 24 | public int getType() { 25 | return ttype; 26 | } 27 | 28 | public void initialize(int t, String txt) { 29 | setType(t); 30 | setText(txt); 31 | } 32 | 33 | public void initialize(AST t) { 34 | setText(t.getText()); 35 | setType(t.getType()); 36 | } 37 | 38 | public CommonAST() { 39 | } 40 | 41 | public CommonAST(Token tok) { 42 | initialize(tok); 43 | } 44 | 45 | public void initialize(Token tok) { 46 | setText(tok.getText()); 47 | setType(tok.getType()); 48 | } 49 | 50 | /** Set the token text for this node */ 51 | public void setText(String text_) { 52 | text = text_; 53 | } 54 | 55 | /** Set the token type for this node */ 56 | public void setType(int ttype_) { 57 | ttype = ttype_; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CommonASTWithHiddenTokens.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/CommonASTWithHiddenTokens.java#2 $ 8 | */ 9 | 10 | import antlr.collections.AST; 11 | 12 | /** A CommonAST whose initialization copies hidden token 13 | * information from the Token used to create a node. 14 | */ 15 | public class CommonASTWithHiddenTokens extends CommonAST { 16 | protected CommonHiddenStreamToken hiddenBefore, hiddenAfter; // references to hidden tokens 17 | 18 | public CommonASTWithHiddenTokens() { 19 | super(); 20 | } 21 | 22 | public CommonASTWithHiddenTokens(Token tok) { 23 | super(tok); 24 | } 25 | 26 | public CommonHiddenStreamToken getHiddenAfter() { 27 | return hiddenAfter; 28 | } 29 | 30 | public CommonHiddenStreamToken getHiddenBefore() { 31 | return hiddenBefore; 32 | } 33 | 34 | public void initialize(AST t) 35 | { 36 | hiddenBefore = ((CommonASTWithHiddenTokens)t).getHiddenBefore(); 37 | hiddenAfter = ((CommonASTWithHiddenTokens)t).getHiddenAfter(); 38 | super.initialize(t); 39 | } 40 | 41 | public void initialize(Token tok) { 42 | CommonHiddenStreamToken t = (CommonHiddenStreamToken)tok; 43 | super.initialize(t); 44 | hiddenBefore = t.getHiddenBefore(); 45 | hiddenAfter = t.getHiddenAfter(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CommonHiddenStreamToken.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/CommonHiddenStreamToken.java#2 $ 8 | */ 9 | 10 | public class CommonHiddenStreamToken extends CommonToken { 11 | protected CommonHiddenStreamToken hiddenBefore; 12 | protected CommonHiddenStreamToken hiddenAfter; 13 | 14 | public CommonHiddenStreamToken() { 15 | super(); 16 | } 17 | 18 | public CommonHiddenStreamToken(int t, String txt) { 19 | super(t, txt); 20 | } 21 | 22 | public CommonHiddenStreamToken(String s) { 23 | super(s); 24 | } 25 | 26 | public CommonHiddenStreamToken getHiddenAfter() { 27 | return hiddenAfter; 28 | } 29 | 30 | public CommonHiddenStreamToken getHiddenBefore() { 31 | return hiddenBefore; 32 | } 33 | 34 | protected void setHiddenAfter(CommonHiddenStreamToken t) { 35 | hiddenAfter = t; 36 | } 37 | 38 | protected void setHiddenBefore(CommonHiddenStreamToken t) { 39 | hiddenBefore = t; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CommonToken.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/CommonToken.java#2 $ 8 | */ 9 | 10 | public class CommonToken extends Token { 11 | // most tokens will want line and text information 12 | protected int line; 13 | protected String text = null; 14 | protected int col; 15 | 16 | public CommonToken() { 17 | } 18 | 19 | public CommonToken(int t, String txt) { 20 | type = t; 21 | setText(txt); 22 | } 23 | 24 | public CommonToken(String s) { 25 | text = s; 26 | } 27 | 28 | public int getLine() { 29 | return line; 30 | } 31 | 32 | public String getText() { 33 | return text; 34 | } 35 | 36 | public void setLine(int l) { 37 | line = l; 38 | } 39 | 40 | public void setText(String s) { 41 | text = s; 42 | } 43 | 44 | public String toString() { 45 | return "[\"" + getText() + "\",<" + type + ">,line=" + line + ",col=" + col + "]"; 46 | } 47 | 48 | /** Return token's start column */ 49 | public int getColumn() { 50 | return col; 51 | } 52 | 53 | public void setColumn(int c) { 54 | col = c; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/CppBlockFinishingInfo.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/CppBlockFinishingInfo.java#2 $ 8 | */ 9 | 10 | // C++ code generator by Pete Wells: pete@yamuna.demon.co.uk 11 | 12 | class CppBlockFinishingInfo { 13 | String postscript; // what to generate to terminate block 14 | boolean generatedSwitch;// did block finish with "default:" of switch? 15 | boolean generatedAnIf; 16 | 17 | /** When generating an if or switch, end-of-token lookahead sets 18 | * will become the else or default clause, don't generate an 19 | * error clause in this case. 20 | */ 21 | boolean needAnErrorClause; 22 | 23 | 24 | public CppBlockFinishingInfo() { 25 | postscript=null; 26 | generatedSwitch=false; 27 | needAnErrorClause = true; 28 | } 29 | public CppBlockFinishingInfo(String ps, boolean genS, boolean generatedAnIf, boolean n) { 30 | postscript = ps; 31 | generatedSwitch = genS; 32 | this.generatedAnIf = generatedAnIf; 33 | needAnErrorClause = n; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/DefaultFileLineFormatter.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/DefaultFileLineFormatter.java#2 $ 8 | */ 9 | 10 | public class DefaultFileLineFormatter extends FileLineFormatter { 11 | public String getFormatString(String fileName, int line, int column) { 12 | StringBuffer buf = new StringBuffer(); 13 | 14 | if (fileName != null) 15 | buf.append(fileName + ":"); 16 | 17 | if (line != -1) { 18 | if (fileName == null) 19 | buf.append("line "); 20 | 21 | buf.append(line); 22 | 23 | if (column != -1) 24 | buf.append(":" + column); 25 | 26 | buf.append(":"); 27 | } 28 | 29 | buf.append(" "); 30 | 31 | return buf.toString(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/ExceptionHandler.java#2 $ 8 | */ 9 | 10 | class ExceptionHandler { 11 | // Type of the ANTLR exception class to catch and the variable decl 12 | protected Token exceptionTypeAndName; 13 | // The action to be executed when the exception is caught 14 | protected Token action; 15 | 16 | 17 | public ExceptionHandler(Token exceptionTypeAndName_, 18 | Token action_) { 19 | exceptionTypeAndName = exceptionTypeAndName_; 20 | action = action_; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ExceptionSpec.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/ExceptionSpec.java#2 $ 8 | */ 9 | 10 | import antlr.collections.impl.Vector; 11 | 12 | class ExceptionSpec { 13 | // Non-null if this refers to a labeled rule 14 | // Use a token instead of a string to get the line information 15 | protected Token label; 16 | 17 | // List of ExceptionHandler (catch phrases) 18 | protected Vector handlers; 19 | 20 | 21 | public ExceptionSpec(Token label_) { 22 | label = label_; 23 | handlers = new Vector(); 24 | } 25 | 26 | public void addHandler(ExceptionHandler handler) { 27 | handlers.appendElement(handler); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/FileCopyException.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/FileCopyException.java#2 $ 8 | */ 9 | 10 | class FileCopyException extends java.io.IOException { 11 | public FileCopyException(String msg) { 12 | super(msg); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/FileLineFormatter.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/FileLineFormatter.java#2 $ 8 | */ 9 | 10 | public abstract class FileLineFormatter { 11 | 12 | private static FileLineFormatter formatter = new DefaultFileLineFormatter(); 13 | 14 | public static FileLineFormatter getFormatter() { 15 | return formatter; 16 | } 17 | 18 | public static void setFormatter(FileLineFormatter f) { 19 | formatter = f; 20 | } 21 | 22 | /** @param fileName the file that should appear in the prefix. (or null) 23 | * @param line the line (or -1) 24 | * @param column the column (or -1) 25 | */ 26 | public abstract String getFormatString(String fileName, int line, int column); 27 | } 28 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/GrammarAnalyzer.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/GrammarAnalyzer.java#2 $ 8 | */ 9 | 10 | /**A GrammarAnalyzer computes lookahead from Grammar (which contains 11 | * a grammar symbol table) and can then answer questions about the 12 | * grammar. 13 | * 14 | * To access the RuleBlock for a rule name, the grammar symbol table 15 | * is consulted. 16 | * 17 | * There should be no distinction between static & dynamic analysis. 18 | * In other words, some of the easy analysis can be done statically 19 | * and then the part that is hard statically can be deferred to 20 | * parse-time. Interestingly, computing LL(k) for k>1 lookahead 21 | * statically is O(|T|^k) where T is the grammar vocabulary, but, 22 | * is O(k) at run-time (ignoring the large constant associated with 23 | * the size of the grammar). In English, the difference can be 24 | * described as "find the set of all possible k-sequences of input" 25 | * versus "does this specific k-sequence match?". 26 | */ 27 | public interface GrammarAnalyzer { 28 | /**The epsilon token type is an imaginary type used 29 | * during analysis. It indicates an incomplete look() computation. 30 | * Must be kept consistent with Token constants to be between 31 | * MIN_USER_TYPE and INVALID_TYPE. 32 | */ 33 | // public static final int EPSILON_TYPE = 2; 34 | public static final int NONDETERMINISTIC = Integer.MAX_VALUE; // lookahead depth 35 | public static final int LOOKAHEAD_DEPTH_INIT = -1; 36 | } 37 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/GrammarSymbol.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/GrammarSymbol.java#2 $ 8 | */ 9 | 10 | /**A GrammarSymbol is a generic symbol that can be 11 | * added to the symbol table for a grammar. 12 | */ 13 | abstract class GrammarSymbol { 14 | protected String id; 15 | 16 | public GrammarSymbol() { 17 | } 18 | 19 | public GrammarSymbol(String s) { 20 | id = s; 21 | } 22 | 23 | public String getId() { 24 | return id; 25 | } 26 | 27 | public void setId(String s) { 28 | id = s; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/JavaBlockFinishingInfo.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/JavaBlockFinishingInfo.java#2 $ 8 | */ 9 | 10 | class JavaBlockFinishingInfo { 11 | String postscript; // what to generate to terminate block 12 | boolean generatedSwitch;// did block finish with "default:" of switch? 13 | boolean generatedAnIf; 14 | 15 | /** When generating an if or switch, end-of-token lookahead sets 16 | * will become the else or default clause, don't generate an 17 | * error clause in this case. 18 | */ 19 | boolean needAnErrorClause; 20 | 21 | 22 | public JavaBlockFinishingInfo() { 23 | postscript = null; 24 | generatedSwitch = generatedSwitch = false; 25 | needAnErrorClause = true; 26 | } 27 | 28 | public JavaBlockFinishingInfo(String ps, boolean genS, boolean generatedAnIf, boolean n) { 29 | postscript = ps; 30 | generatedSwitch = genS; 31 | this.generatedAnIf = generatedAnIf; 32 | needAnErrorClause = n; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/JavaCodeGeneratorPrintWriterManager.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.util.Map; 6 | 7 | /** 8 | * Defines a strategy that can be used to manage the printwriter 9 | * being used to write JavaCodeGenerator output 10 | * 11 | * TODO generalize so all code gens could use? 12 | */ 13 | public interface JavaCodeGeneratorPrintWriterManager { 14 | public PrintWriter setupOutput(Tool tool, Grammar grammar) throws IOException; 15 | public PrintWriter setupOutput(Tool tool, String fileName) throws IOException; 16 | public void startMapping(int sourceLine); 17 | public void startSingleSourceLineMapping(int sourceLine); 18 | public void endMapping(); 19 | public void finishOutput() throws IOException; 20 | public Map getSourceMaps(); 21 | } 22 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/NoViableAltException.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/NoViableAltException.java#2 $ 8 | */ 9 | 10 | import antlr.collections.AST; 11 | 12 | public class NoViableAltException extends RecognitionException { 13 | public Token token; 14 | public AST node; // handles parsing and treeparsing 15 | 16 | public NoViableAltException(AST t) { 17 | super("NoViableAlt", "", t.getLine(), t.getColumn()); 18 | node = t; 19 | } 20 | 21 | public NoViableAltException(Token t, String fileName_) { 22 | super("NoViableAlt", fileName_, t.getLine(), t.getColumn()); 23 | token = t; 24 | } 25 | 26 | /** 27 | * Returns a clean error message (no line number/column information) 28 | */ 29 | public String getMessage() { 30 | if (token != null) { 31 | return "unexpected token: " + token.getText(); 32 | } 33 | 34 | // must a tree parser error if token==null 35 | if (node == TreeParser.ASTNULL) { 36 | return "unexpected end of subtree"; 37 | } 38 | return "unexpected AST node: " + node.toString(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/OneOrMoreBlock.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/OneOrMoreBlock.java#2 $ 8 | */ 9 | 10 | class OneOrMoreBlock extends BlockWithImpliedExitPath { 11 | 12 | public OneOrMoreBlock(Grammar g) { 13 | super(g); 14 | } 15 | 16 | public OneOrMoreBlock(Grammar g, Token start) { 17 | super(g, start); 18 | } 19 | 20 | public void generate() { 21 | grammar.generator.gen(this); 22 | } 23 | 24 | public Lookahead look(int k) { 25 | return grammar.theLLkAnalyzer.look(k, this); 26 | } 27 | 28 | public String toString() { 29 | return super.toString() + "+"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ParseTree.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | */ 7 | 8 | import antlr.*; 9 | import antlr.collections.AST; 10 | 11 | public abstract class ParseTree extends BaseAST { 12 | 13 | /** Walk parse tree and return requested number of derivation steps. 14 | * If steps <= 0, return node text. If steps == 1, return derivation 15 | * string at step. 16 | */ 17 | public String getLeftmostDerivationStep(int step) { 18 | if ( step<=0 ) { 19 | return toString(); 20 | } 21 | StringBuffer buf = new StringBuffer(2000); 22 | getLeftmostDerivation(buf, step); 23 | return buf.toString(); 24 | } 25 | 26 | public String getLeftmostDerivation(int maxSteps) { 27 | StringBuffer buf = new StringBuffer(2000); 28 | buf.append(" "+this.toString()); 29 | buf.append("\n"); 30 | for (int d=1; d"); 32 | buf.append(getLeftmostDerivationStep(d)); 33 | buf.append("\n"); 34 | } 35 | return buf.toString(); 36 | } 37 | 38 | /** Get derivation and return how many you did (less than requested for 39 | * subtree roots. 40 | */ 41 | protected abstract int getLeftmostDerivation(StringBuffer buf, int step); 42 | 43 | // just satisfy BaseAST interface; unused as we manually create nodes 44 | 45 | public void initialize(int i, String s) { 46 | } 47 | public void initialize(AST ast) { 48 | } 49 | public void initialize(Token token) { 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ParseTreeToken.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | */ 7 | 8 | import antlr.Token; 9 | import antlr.collections.AST; 10 | 11 | public class ParseTreeToken extends ParseTree { 12 | protected Token token; 13 | 14 | public ParseTreeToken(Token token) { 15 | this.token = token; 16 | } 17 | 18 | protected int getLeftmostDerivation(StringBuffer buf, int step) { 19 | buf.append(' '); 20 | buf.append(toString()); 21 | return step; // did on replacements 22 | } 23 | 24 | public String toString() { 25 | if ( token!=null ) { 26 | return token.getText(); 27 | } 28 | return ""; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ParserSharedInputState.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/ParserSharedInputState.java#2 $ 8 | */ 9 | 10 | /** This object contains the data associated with an 11 | * input stream of tokens. Multiple parsers 12 | * share a single ParserSharedInputState to parse 13 | * the same stream of tokens. 14 | */ 15 | public class ParserSharedInputState { 16 | /** Where to get token objects */ 17 | protected TokenBuffer input; 18 | 19 | /** Are we guessing (guessing>0)? */ 20 | public int guessing = 0; 21 | 22 | /** What file (if known) caused the problem? */ 23 | protected String filename; 24 | 25 | public void reset() { 26 | guessing = 0; 27 | filename = null; 28 | input.reset(); 29 | } 30 | 31 | public String getFilename() { 32 | return filename; 33 | } 34 | 35 | public TokenBuffer getInput() { 36 | return input; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/PythonBlockFinishingInfo.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/RIGHTS.html 6 | * 7 | * $Id$ 8 | */ 9 | 10 | class PythonBlockFinishingInfo { 11 | String postscript; // what to generate to terminate block 12 | boolean generatedSwitch;// did block finish with "default:" of switch? 13 | boolean generatedAnIf; 14 | 15 | /** When generating an if or switch, end-of-token lookahead sets 16 | * will become the else or default clause, don't generate an 17 | * error clause in this case. 18 | */ 19 | boolean needAnErrorClause; 20 | 21 | 22 | public PythonBlockFinishingInfo() { 23 | postscript = null; 24 | generatedSwitch = generatedSwitch = false; 25 | needAnErrorClause = true; 26 | } 27 | 28 | public PythonBlockFinishingInfo(String ps, boolean genS, boolean generatedAnIf, boolean n) { 29 | postscript = ps; 30 | generatedSwitch = genS; 31 | this.generatedAnIf = generatedAnIf; 32 | needAnErrorClause = n; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/RuleEndElement.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/RuleEndElement.java#2 $ 8 | */ 9 | 10 | /**Contains a list of all places that reference 11 | * this enclosing rule. Useful for FOLLOW computations. 12 | */ 13 | class RuleEndElement extends BlockEndElement { 14 | protected Lookahead[] cache; // Each rule can cache it's lookahead computation. 15 | // The FOLLOW(rule) is stored in this cache. 16 | // 1..k 17 | protected boolean noFOLLOW; 18 | 19 | 20 | public RuleEndElement(Grammar g) { 21 | super(g); 22 | cache = new Lookahead[g.maxk + 1]; 23 | } 24 | 25 | public Lookahead look(int k) { 26 | return grammar.theLLkAnalyzer.look(k, this); 27 | } 28 | 29 | public String toString() { 30 | //return " [RuleEnd]"; 31 | return ""; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/RuleSymbol.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/RuleSymbol.java#2 $ 8 | */ 9 | 10 | import antlr.collections.impl.Vector; 11 | 12 | class RuleSymbol extends GrammarSymbol { 13 | RuleBlock block; // list of alternatives 14 | boolean defined; // has the rule been defined yet? 15 | Vector references; // list of all nodes referencing this rule 16 | // not strictly needed by generic symbol table 17 | // but we will almost always analyze/gen code 18 | String access; // access specifier for this rule 19 | String comment; // A javadoc comment if any. 20 | 21 | public RuleSymbol(String r) { 22 | super(r); 23 | references = new Vector(); 24 | } 25 | 26 | public void addReference(RuleRefElement e) { 27 | references.appendElement(e); 28 | } 29 | 30 | public RuleBlock getBlock() { 31 | return block; 32 | } 33 | 34 | public RuleRefElement getReference(int i) { 35 | return (RuleRefElement)references.elementAt(i); 36 | } 37 | 38 | public boolean isDefined() { 39 | return defined; 40 | } 41 | 42 | public int numReferences() { 43 | return references.size(); 44 | } 45 | 46 | public void setBlock(RuleBlock rb) { 47 | block = rb; 48 | } 49 | 50 | public void setDefined() { 51 | defined = true; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/SemanticException.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/SemanticException.java#2 $ 8 | */ 9 | 10 | public class SemanticException extends RecognitionException { 11 | public SemanticException(String s) { 12 | super(s); 13 | } 14 | 15 | /** @deprecated As of ANTLR 2.7.2 use {@see #SemanticException(char, String, int, int) } */ 16 | public SemanticException(String s, String fileName, int line) { 17 | this(s, fileName, line, -1); 18 | } 19 | 20 | public SemanticException(String s, String fileName, int line, int column) { 21 | super(s, fileName, line, column); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/StringLiteralSymbol.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/StringLiteralSymbol.java#2 $ 8 | */ 9 | 10 | class StringLiteralSymbol extends TokenSymbol { 11 | protected String label; // was this string literal labeled? 12 | 13 | 14 | public StringLiteralSymbol(String r) { 15 | super(r); 16 | } 17 | 18 | public String getLabel() { 19 | return label; 20 | } 21 | 22 | public void setLabel(String label) { 23 | this.label = label; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/SynPredBlock.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/SynPredBlock.java#2 $ 8 | */ 9 | 10 | class SynPredBlock extends AlternativeBlock { 11 | 12 | public SynPredBlock(Grammar g) { 13 | super(g); 14 | } 15 | 16 | public SynPredBlock(Grammar g, Token start) { 17 | super(g, start, false); 18 | } 19 | 20 | public void generate() { 21 | grammar.generator.gen(this); 22 | } 23 | 24 | public Lookahead look(int k) { 25 | return grammar.theLLkAnalyzer.look(k, this); 26 | } 27 | 28 | public String toString() { 29 | return super.toString() + "=>"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TokenRangeElement.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TokenRangeElement.java#2 $ 8 | */ 9 | 10 | class TokenRangeElement extends AlternativeElement { 11 | String label; 12 | protected int begin = Token.INVALID_TYPE; 13 | protected int end = Token.INVALID_TYPE; 14 | protected String beginText; 15 | protected String endText; 16 | 17 | public TokenRangeElement(Grammar g, Token t1, Token t2, int autoGenType) { 18 | super(g, t1, autoGenType); 19 | begin = grammar.tokenManager.getTokenSymbol(t1.getText()).getTokenType(); 20 | beginText = t1.getText(); 21 | end = grammar.tokenManager.getTokenSymbol(t2.getText()).getTokenType(); 22 | endText = t2.getText(); 23 | line = t1.getLine(); 24 | } 25 | 26 | public void generate() { 27 | grammar.generator.gen(this); 28 | } 29 | 30 | public String getLabel() { 31 | return label; 32 | } 33 | 34 | public Lookahead look(int k) { 35 | return grammar.theLLkAnalyzer.look(k, this); 36 | } 37 | 38 | public void setLabel(String label_) { 39 | label = label_; 40 | } 41 | 42 | public String toString() { 43 | if (label != null) { 44 | return " " + label + ":" + beginText + ".." + endText; 45 | } 46 | else { 47 | return " " + beginText + ".." + endText; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TokenRefElement.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TokenRefElement.java#2 $ 8 | */ 9 | 10 | class TokenRefElement extends GrammarAtom { 11 | 12 | public TokenRefElement(Grammar g, 13 | Token t, 14 | boolean inverted, 15 | int autoGenType) { 16 | super(g, t, autoGenType); 17 | not = inverted; 18 | TokenSymbol ts = grammar.tokenManager.getTokenSymbol(atomText); 19 | if (ts == null) { 20 | g.antlrTool.error("Undefined token symbol: " + 21 | atomText, grammar.getFilename(), t.getLine(), t.getColumn()); 22 | } 23 | else { 24 | tokenType = ts.getTokenType(); 25 | // set the AST node type to whatever was set in tokens {...} 26 | // section (if anything); 27 | // Lafter, after this is created, the element option can set this. 28 | setASTNodeType(ts.getASTNodeType()); 29 | } 30 | line = t.getLine(); 31 | } 32 | 33 | public void generate() { 34 | grammar.generator.gen(this); 35 | } 36 | 37 | public Lookahead look(int k) { 38 | return grammar.theLLkAnalyzer.look(k, this); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TokenStream.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TokenStream.java#2 $ 8 | */ 9 | 10 | public interface TokenStream { 11 | public Token nextToken() throws TokenStreamException; 12 | } 13 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TokenStreamException.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TokenStreamException.java#2 $ 8 | */ 9 | 10 | /** 11 | * Anything that goes wrong while generating a stream of tokens. 12 | */ 13 | public class TokenStreamException extends ANTLRException { 14 | public TokenStreamException() { 15 | } 16 | 17 | public TokenStreamException(String s) { 18 | super(s); 19 | } 20 | 21 | public TokenStreamException(String message, Throwable cause) { 22 | super(message, cause); 23 | } 24 | 25 | public TokenStreamException(Throwable cause) { 26 | super(cause); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TokenStreamIOException.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TokenStreamIOException.java#2 $ 8 | */ 9 | 10 | import java.io.IOException; 11 | 12 | /** 13 | * Wraps an IOException in a TokenStreamException 14 | */ 15 | public class TokenStreamIOException extends TokenStreamException { 16 | public IOException io; 17 | 18 | /** 19 | * TokenStreamIOException constructor comment. 20 | * @param s java.lang.String 21 | */ 22 | public TokenStreamIOException(IOException io) { 23 | super(io.getMessage()); 24 | this.io = io; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TokenStreamRecognitionException.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TokenStreamRecognitionException.java#2 $ 8 | */ 9 | 10 | /** 11 | * Wraps a RecognitionException in a TokenStreamException so you 12 | * can pass it along. 13 | */ 14 | public class TokenStreamRecognitionException extends TokenStreamException { 15 | public RecognitionException recog; 16 | 17 | public TokenStreamRecognitionException(RecognitionException re) { 18 | super(re.getMessage()); 19 | this.recog = re; 20 | } 21 | 22 | public String toString() { 23 | return recog.toString(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TokenStreamRetryException.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TokenStreamRetryException.java#2 $ 8 | */ 9 | 10 | /** 11 | * Aborted recognition of current token. Try to get one again. 12 | * Used by TokenStreamSelector.retry() to force nextToken() 13 | * of stream to re-enter and retry. 14 | */ 15 | public class TokenStreamRetryException extends TokenStreamException { 16 | public TokenStreamRetryException() { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TokenSymbol.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TokenSymbol.java#2 $ 8 | */ 9 | 10 | class TokenSymbol extends GrammarSymbol { 11 | protected int ttype; 12 | /** describes what token matches in "human terms" */ 13 | protected String paraphrase = null; 14 | 15 | /** Set to a value in the tokens {...} section */ 16 | protected String ASTNodeType; 17 | 18 | public TokenSymbol(String r) { 19 | super(r); 20 | ttype = Token.INVALID_TYPE; 21 | } 22 | 23 | public String getASTNodeType() { 24 | return ASTNodeType; 25 | } 26 | 27 | public void setASTNodeType(String type) { 28 | ASTNodeType = type; 29 | } 30 | 31 | public String getParaphrase() { 32 | return paraphrase; 33 | } 34 | 35 | public int getTokenType() { 36 | return ttype; 37 | } 38 | 39 | public void setParaphrase(String p) { 40 | paraphrase = p; 41 | } 42 | 43 | public void setTokenType(int t) { 44 | ttype = t; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TokenWithIndex.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | */ 7 | 8 | /** This token knows what index 0..n-1 it is from beginning of stream. 9 | * Designed to work with TokenStreamRewriteEngine.java 10 | */ 11 | public class TokenWithIndex extends CommonToken { 12 | /** Index into token array indicating position in input stream */ 13 | int index; 14 | 15 | public TokenWithIndex() { 16 | super(); 17 | } 18 | 19 | public TokenWithIndex(int i, String t) { 20 | super(i,t); 21 | } 22 | 23 | public void setIndex(int i) { 24 | index = i; 25 | } 26 | 27 | public int getIndex() { 28 | return index; 29 | } 30 | 31 | public String toString() { 32 | return "["+index+":\"" + getText() + "\",<" + getType() + ">,line=" + line + ",col=" + 33 | col + "]\n"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TreeBlockContext.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TreeBlockContext.java#2 $ 8 | */ 9 | 10 | /**The context needed to add root,child elements to a Tree. There 11 | * is only one alternative (i.e., a list of children). We subclass to 12 | * specialize. MakeGrammar.addElementToCurrentAlt will work correctly 13 | * now for either a block of alts or a Tree child list. 14 | * 15 | * The first time addAlternativeElement is called, it sets the root element 16 | * rather than adding it to one of the alternative lists. Rather than have 17 | * the grammar duplicate the rules for grammar atoms etc... we use the same 18 | * grammar and same refToken behavior etc... We have to special case somewhere 19 | * and here is where we do it. 20 | */ 21 | class TreeBlockContext extends BlockContext { 22 | protected boolean nextElementIsRoot = true; 23 | 24 | 25 | public void addAlternativeElement(AlternativeElement e) { 26 | TreeElement tree = (TreeElement)block; 27 | if (nextElementIsRoot) { 28 | tree.root = (GrammarAtom)e; 29 | nextElementIsRoot = false; 30 | } 31 | else { 32 | super.addAlternativeElement(e); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TreeElement.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TreeElement.java#2 $ 8 | */ 9 | 10 | /** A TreeElement is a block with one alternative and a root node */ 11 | class TreeElement extends AlternativeBlock { 12 | GrammarAtom root; 13 | 14 | public TreeElement(Grammar g, Token start) { 15 | super(g, start, false); 16 | } 17 | 18 | public void generate() { 19 | grammar.generator.gen(this); 20 | } 21 | 22 | public Lookahead look(int k) { 23 | return grammar.theLLkAnalyzer.look(k, this); 24 | } 25 | 26 | public String toString() { 27 | String s = " #(" + root; 28 | Alternative a = (Alternative)alternatives.elementAt(0); 29 | AlternativeElement p = a.head; 30 | while (p != null) { 31 | s += p; 32 | p = p.next; 33 | } 34 | return s + " )"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TreeParserSharedInputState.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TreeParserSharedInputState.java#2 $ 8 | */ 9 | 10 | /** This object contains the data associated with an 11 | * input AST. Multiple parsers 12 | * share a single TreeParserSharedInputState to parse 13 | * the same tree or to have the parser walk multiple 14 | * trees. 15 | */ 16 | public class TreeParserSharedInputState { 17 | /** Are we guessing (guessing>0)? */ 18 | public int guessing = 0; 19 | } 20 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/TreeSpecifierNode.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/TreeSpecifierNode.java#2 $ 8 | */ 9 | 10 | class TreeSpecifierNode { 11 | private TreeSpecifierNode parent = null; 12 | private TreeSpecifierNode firstChild = null; 13 | private TreeSpecifierNode nextSibling = null; 14 | private Token tok; 15 | 16 | 17 | TreeSpecifierNode(Token tok_) { 18 | tok = tok_; 19 | } 20 | 21 | public TreeSpecifierNode getFirstChild() { 22 | return firstChild; 23 | } 24 | 25 | public TreeSpecifierNode getNextSibling() { 26 | return nextSibling; 27 | } 28 | 29 | // Accessors 30 | public TreeSpecifierNode getParent() { 31 | return parent; 32 | } 33 | 34 | public Token getToken() { 35 | return tok; 36 | } 37 | 38 | public void setFirstChild(TreeSpecifierNode child) { 39 | firstChild = child; 40 | child.parent = this; 41 | } 42 | 43 | // Structure-building 44 | public void setNextSibling(TreeSpecifierNode sibling) { 45 | nextSibling = sibling; 46 | sibling.parent = parent; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/Utils.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | public class Utils { 4 | private static boolean useSystemExit = true; 5 | private static boolean useDirectClassLoading = false; 6 | static { 7 | if ("true".equalsIgnoreCase(System.getProperty("ANTLR_DO_NOT_EXIT", "false"))) 8 | useSystemExit = false; 9 | if ("true".equalsIgnoreCase(System.getProperty("ANTLR_USE_DIRECT_CLASS_LOADING", "false"))) 10 | useDirectClassLoading = true; 11 | } 12 | 13 | /** Thanks to Max Andersen at JBOSS and Scott Stanchfield */ 14 | public static Class loadClass(String name) throws ClassNotFoundException { 15 | try { 16 | ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); 17 | if (!useDirectClassLoading && contextClassLoader!=null ) { 18 | return contextClassLoader.loadClass(name); 19 | } 20 | return Class.forName(name); 21 | } 22 | catch (Exception e) { 23 | return Class.forName(name); 24 | } 25 | } 26 | 27 | public static Object createInstanceOf(String name) throws ClassNotFoundException, InstantiationException, IllegalAccessException { 28 | return loadClass(name).newInstance(); 29 | } 30 | 31 | public static void error(String message) { 32 | if (useSystemExit) 33 | System.exit(1); 34 | throw new RuntimeException("ANTLR Panic: " + message); 35 | } 36 | 37 | public static void error(String message, Throwable t) { 38 | if (useSystemExit) 39 | System.exit(1); 40 | throw new RuntimeException("ANTLR Panic", t); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/Version.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | public class Version { 4 | public static final String version = "2"; 5 | public static final String subversion = "7"; 6 | public static final String patchlevel = "7"; 7 | public static final String datestamp = "2006-11-01"; 8 | public static final String project_version = "2.7.7 ("+datestamp+")"; 9 | } 10 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/Version.java.in: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | public class Version { 4 | public static final String version = "@VERSION@"; 5 | public static final String subversion = "@SUBVERSION@"; 6 | public static final String patchlevel = "@PATCHLEVEL@"; 7 | public static final String datestamp = "@TIMESTAMP@"; 8 | public static final String project_version = "@PACKAGE_VERSION@ (@TIMESTAMP@)"; 9 | } 10 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/WildcardElement.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/WildcardElement.java#2 $ 8 | */ 9 | 10 | class WildcardElement extends GrammarAtom { 11 | protected String label; 12 | 13 | public WildcardElement(Grammar g, Token t, int autoGenType) { 14 | super(g, t, autoGenType); 15 | line = t.getLine(); 16 | } 17 | 18 | public void generate() { 19 | grammar.generator.gen(this); 20 | } 21 | 22 | public String getLabel() { 23 | return label; 24 | } 25 | 26 | public Lookahead look(int k) { 27 | return grammar.theLLkAnalyzer.look(k, this); 28 | } 29 | 30 | public void setLabel(String label_) { 31 | label = label_; 32 | } 33 | 34 | public String toString() { 35 | String s = " "; 36 | if (label != null) s += label + ":"; 37 | return s + "."; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/ZeroOrMoreBlock.java: -------------------------------------------------------------------------------- 1 | package antlr; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/ZeroOrMoreBlock.java#2 $ 8 | */ 9 | 10 | class ZeroOrMoreBlock extends BlockWithImpliedExitPath { 11 | 12 | public ZeroOrMoreBlock(Grammar g) { 13 | super(g); 14 | } 15 | 16 | public ZeroOrMoreBlock(Grammar g, Token start) { 17 | super(g, start); 18 | } 19 | 20 | public void generate() { 21 | grammar.generator.gen(this); 22 | } 23 | 24 | public Lookahead look(int k) { 25 | return grammar.theLLkAnalyzer.look(k, this); 26 | } 27 | 28 | public String toString() { 29 | return super.toString() + "*"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/actions/cpp/ActionLexerTokenTypes.java: -------------------------------------------------------------------------------- 1 | // $ANTLR : "action.g" -> "ActionLexer.java"$ 2 | 3 | package antlr.actions.cpp; 4 | 5 | public interface ActionLexerTokenTypes { 6 | int EOF = 1; 7 | int NULL_TREE_LOOKAHEAD = 3; 8 | int ACTION = 4; 9 | int STUFF = 5; 10 | int AST_ITEM = 6; 11 | int TEXT_ITEM = 7; 12 | int TREE = 8; 13 | int TREE_ELEMENT = 9; 14 | int AST_CONSTRUCTOR = 10; 15 | int AST_CTOR_ELEMENT = 11; 16 | int ID_ELEMENT = 12; 17 | int TEXT_ARG = 13; 18 | int TEXT_ARG_ELEMENT = 14; 19 | int TEXT_ARG_ID_ELEMENT = 15; 20 | int ARG = 16; 21 | int ID = 17; 22 | int VAR_ASSIGN = 18; 23 | int COMMENT = 19; 24 | int SL_COMMENT = 20; 25 | int ML_COMMENT = 21; 26 | int CHAR = 22; 27 | int STRING = 23; 28 | int ESC = 24; 29 | int DIGIT = 25; 30 | int INT = 26; 31 | int INT_OR_FLOAT = 27; 32 | int WS = 28; 33 | } 34 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/actions/csharp/ActionLexerTokenTypes.java: -------------------------------------------------------------------------------- 1 | // $ANTLR : "action.g" -> "ActionLexer.java"$ 2 | 3 | package antlr.actions.csharp; 4 | 5 | public interface ActionLexerTokenTypes { 6 | int EOF = 1; 7 | int NULL_TREE_LOOKAHEAD = 3; 8 | int ACTION = 4; 9 | int STUFF = 5; 10 | int AST_ITEM = 6; 11 | int TEXT_ITEM = 7; 12 | int TREE = 8; 13 | int TREE_ELEMENT = 9; 14 | int AST_CONSTRUCTOR = 10; 15 | int AST_CTOR_ELEMENT = 11; 16 | int ID_ELEMENT = 12; 17 | int TEXT_ARG = 13; 18 | int TEXT_ARG_ELEMENT = 14; 19 | int TEXT_ARG_ID_ELEMENT = 15; 20 | int ARG = 16; 21 | int ID = 17; 22 | int VAR_ASSIGN = 18; 23 | int COMMENT = 19; 24 | int SL_COMMENT = 20; 25 | int ML_COMMENT = 21; 26 | int CHAR = 22; 27 | int STRING = 23; 28 | int ESC = 24; 29 | int DIGIT = 25; 30 | int INT = 26; 31 | int INT_OR_FLOAT = 27; 32 | int WS = 28; 33 | } 34 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/actions/java/ActionLexerTokenTypes.java: -------------------------------------------------------------------------------- 1 | // $ANTLR : "action.g" -> "ActionLexer.java"$ 2 | 3 | package antlr.actions.java; 4 | 5 | public interface ActionLexerTokenTypes { 6 | int EOF = 1; 7 | int NULL_TREE_LOOKAHEAD = 3; 8 | int ACTION = 4; 9 | int STUFF = 5; 10 | int AST_ITEM = 6; 11 | int TEXT_ITEM = 7; 12 | int TREE = 8; 13 | int TREE_ELEMENT = 9; 14 | int AST_CONSTRUCTOR = 10; 15 | int AST_CTOR_ELEMENT = 11; 16 | int ID_ELEMENT = 12; 17 | int TEXT_ARG = 13; 18 | int TEXT_ARG_ELEMENT = 14; 19 | int TEXT_ARG_ID_ELEMENT = 15; 20 | int ARG = 16; 21 | int ID = 17; 22 | int VAR_ASSIGN = 18; 23 | int COMMENT = 19; 24 | int SL_COMMENT = 20; 25 | int ML_COMMENT = 21; 26 | int CHAR = 22; 27 | int STRING = 23; 28 | int ESC = 24; 29 | int DIGIT = 25; 30 | int INT = 26; 31 | int INT_OR_FLOAT = 27; 32 | int WS = 28; 33 | } 34 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/actions/python/ActionLexerTokenTypes.java: -------------------------------------------------------------------------------- 1 | // $ANTLR 2.7.5RC1 (20041124-137): "action.g" -> "ActionLexer.java"$ 2 | 3 | package antlr.actions.python; 4 | 5 | public interface ActionLexerTokenTypes { 6 | int EOF = 1; 7 | int NULL_TREE_LOOKAHEAD = 3; 8 | int ACTION = 4; 9 | int STUFF = 5; 10 | int AST_ITEM = 6; 11 | int TEXT_ITEM = 7; 12 | int TREE = 8; 13 | int TREE_ELEMENT = 9; 14 | int AST_CONSTRUCTOR = 10; 15 | int AST_CTOR_ELEMENT = 11; 16 | int ID_ELEMENT = 12; 17 | int TEXT_ARG = 13; 18 | int TEXT_ARG_ELEMENT = 14; 19 | int TEXT_ARG_ID_ELEMENT = 15; 20 | int ARG = 16; 21 | int ID = 17; 22 | int VAR_ASSIGN = 18; 23 | int COMMENT = 19; 24 | int SL_COMMENT = 20; 25 | int IGNWS = 21; 26 | int ML_COMMENT = 22; 27 | int CHAR = 23; 28 | int STRING = 24; 29 | int ESC = 25; 30 | int DIGIT = 26; 31 | int INT = 27; 32 | int INT_OR_FLOAT = 28; 33 | int WS = 29; 34 | } 35 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/actions/python/CodeLexerTokenTypes.java: -------------------------------------------------------------------------------- 1 | // $ANTLR 2.7.5RC1 (20041124-137): "code.g" -> "CodeLexer.java"$ 2 | 3 | package antlr.actions.python; 4 | 5 | public interface CodeLexerTokenTypes { 6 | int EOF = 1; 7 | int NULL_TREE_LOOKAHEAD = 3; 8 | int ACTION = 4; 9 | int STUFF = 5; 10 | int COMMENT = 6; 11 | int SL_COMMENT = 7; 12 | int IGNWS = 8; 13 | int ML_COMMENT = 9; 14 | } 15 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/build/StreamScarfer.java: -------------------------------------------------------------------------------- 1 | package antlr.build; 2 | 3 | import java.util.*; 4 | import java.io.*; 5 | 6 | /** Adapted from JavaWorld article by Michael Daconta */ 7 | class StreamScarfer extends Thread 8 | { 9 | InputStream is; 10 | String type; 11 | Tool tool; 12 | 13 | StreamScarfer(InputStream is, String type, Tool tool) { 14 | this.is = is; 15 | this.type = type; 16 | this.tool = tool; 17 | } 18 | 19 | public void run() { 20 | try { 21 | InputStreamReader isr = new InputStreamReader(is); 22 | BufferedReader br = new BufferedReader(isr); 23 | String line=null; 24 | while ( (line = br.readLine()) != null) { 25 | if ( type==null || type.equals("stdout") ) { 26 | tool.stdout(line); 27 | } 28 | else { 29 | tool.stderr(line); 30 | } 31 | } 32 | } 33 | catch (IOException ioe) { 34 | ioe.printStackTrace(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/collections/ASTEnumeration.java: -------------------------------------------------------------------------------- 1 | package antlr.collections; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/collections/ASTEnumeration.java#2 $ 8 | */ 9 | 10 | public interface ASTEnumeration { 11 | public boolean hasMoreNodes(); 12 | 13 | public AST nextNode(); 14 | } 15 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/collections/Enumerator.java: -------------------------------------------------------------------------------- 1 | package antlr.collections; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/collections/Enumerator.java#2 $ 8 | */ 9 | 10 | public interface Enumerator { 11 | /**Return the element under the cursor; return null if !valid() or 12 | * if called before first next() call. 13 | */ 14 | public Object cursor(); 15 | 16 | /**Return the next element in the enumeration; first call to next() 17 | * returns the first element. 18 | */ 19 | public Object next(); 20 | 21 | /**Any more elements in the enumeration? */ 22 | public boolean valid(); 23 | } 24 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/collections/List.java: -------------------------------------------------------------------------------- 1 | package antlr.collections; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/collections/List.java#2 $ 8 | */ 9 | 10 | import java.util.Enumeration; 11 | import java.util.NoSuchElementException; 12 | 13 | /**A simple List interface that describes operations 14 | * on a list. 15 | */ 16 | public interface List { 17 | public void add(Object o); // can insert at head or append. 18 | 19 | public void append(Object o); 20 | 21 | public Object elementAt(int index) throws NoSuchElementException; 22 | 23 | public Enumeration elements(); 24 | 25 | public boolean includes(Object o); 26 | 27 | public int length(); 28 | } 29 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/collections/Stack.java: -------------------------------------------------------------------------------- 1 | package antlr.collections; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/collections/Stack.java#2 $ 8 | */ 9 | 10 | import java.util.NoSuchElementException; 11 | 12 | /** A simple stack definition; restrictive in that you cannot 13 | * access arbitrary stack elements. 14 | * 15 | * @author Terence Parr 16 | * MageLang Institute 17 | */ 18 | public interface Stack { 19 | public int height(); 20 | 21 | public Object pop() throws NoSuchElementException; 22 | 23 | public void push(Object o); 24 | 25 | public Object top() throws NoSuchElementException; 26 | } 27 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/collections/impl/ASTArray.java: -------------------------------------------------------------------------------- 1 | package antlr.collections.impl; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/collections/impl/ASTArray.java#2 $ 8 | */ 9 | 10 | import antlr.collections.AST; 11 | 12 | /** ASTArray is a class that allows ANTLR to 13 | * generate code that can create and initialize an array 14 | * in one expression, like: 15 | * (new ASTArray(3)).add(x).add(y).add(z) 16 | */ 17 | public class ASTArray { 18 | public int size = 0; 19 | public AST[] array; 20 | 21 | 22 | public ASTArray(int capacity) { 23 | array = new AST[capacity]; 24 | } 25 | 26 | public ASTArray add(AST node) { 27 | array[size++] = node; 28 | return this; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/collections/impl/ASTEnumerator.java: -------------------------------------------------------------------------------- 1 | package antlr.collections.impl; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/collections/impl/ASTEnumerator.java#2 $ 8 | */ 9 | 10 | import antlr.collections.impl.Vector; 11 | import antlr.collections.ASTEnumeration; 12 | import antlr.collections.AST; 13 | 14 | import java.util.NoSuchElementException; 15 | 16 | public class ASTEnumerator implements antlr.collections.ASTEnumeration { 17 | /** The list of root nodes for subtrees that match */ 18 | VectorEnumerator nodes; 19 | int i = 0; 20 | 21 | 22 | public ASTEnumerator(Vector v) { 23 | nodes = new VectorEnumerator(v); 24 | } 25 | 26 | public boolean hasMoreNodes() { 27 | synchronized (nodes) { 28 | return i <= nodes.vector.lastElement; 29 | } 30 | } 31 | 32 | public antlr.collections.AST nextNode() { 33 | synchronized (nodes) { 34 | if (i <= nodes.vector.lastElement) { 35 | return (AST)nodes.vector.data[i++]; 36 | } 37 | throw new NoSuchElementException("ASTEnumerator"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/collections/impl/IntRange.java: -------------------------------------------------------------------------------- 1 | package antlr.collections.impl; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/collections/impl/IntRange.java#2 $ 8 | */ 9 | 10 | public class IntRange { 11 | int begin, end; 12 | 13 | 14 | public IntRange(int begin, int end) { 15 | this.begin = begin; 16 | this.end = end; 17 | } 18 | 19 | public String toString() { 20 | return begin + ".." + end; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/collections/impl/LLCell.java: -------------------------------------------------------------------------------- 1 | package antlr.collections.impl; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/collections/impl/LLCell.java#2 $ 8 | */ 9 | 10 | /**A linked list cell, which contains a ref to the object and next cell. 11 | * The data,next members are public to this class, but not outside the 12 | * collections.impl package. 13 | * 14 | * @author Terence Parr 15 | * MageLang Institute 16 | */ 17 | class LLCell { 18 | Object data; 19 | LLCell next; 20 | 21 | 22 | public LLCell(Object o) { 23 | data = o; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/collections/impl/VectorEnumeration.java: -------------------------------------------------------------------------------- 1 | package antlr.collections.impl; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/collections/impl/VectorEnumeration.java#2 $ 8 | */ 9 | 10 | import java.util.Enumeration; 11 | import java.util.NoSuchElementException; 12 | 13 | import antlr.collections.Enumerator; 14 | 15 | // based on java.lang.Vector; returns any null indices between non-null ones. 16 | 17 | class VectorEnumeration implements Enumeration { 18 | Vector vector; 19 | int i; 20 | 21 | 22 | VectorEnumeration(Vector v) { 23 | vector = v; 24 | i = 0; 25 | } 26 | 27 | public boolean hasMoreElements() { 28 | synchronized (vector) { 29 | return i <= vector.lastElement; 30 | } 31 | } 32 | 33 | public Object nextElement() { 34 | synchronized (vector) { 35 | if (i <= vector.lastElement) { 36 | return vector.data[i++]; 37 | } 38 | throw new NoSuchElementException("VectorEnumerator"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/collections/impl/VectorEnumerator.java: -------------------------------------------------------------------------------- 1 | package antlr.collections.impl; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/collections/impl/VectorEnumerator.java#2 $ 8 | */ 9 | 10 | import java.util.Enumeration; 11 | import java.util.NoSuchElementException; 12 | 13 | import antlr.collections.Enumerator; 14 | 15 | // based on java.lang.Vector; returns any null indices between non-null ones. 16 | 17 | class VectorEnumerator implements Enumeration { 18 | Vector vector; 19 | int i; 20 | 21 | 22 | VectorEnumerator(Vector v) { 23 | vector = v; 24 | i = 0; 25 | } 26 | 27 | public boolean hasMoreElements() { 28 | synchronized (vector) { 29 | return i <= vector.lastElement; 30 | } 31 | } 32 | 33 | public Object nextElement() { 34 | synchronized (vector) { 35 | if (i <= vector.lastElement) { 36 | return vector.data[i++]; 37 | } 38 | throw new NoSuchElementException("VectorEnumerator"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/DebuggingParser.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | /** 4 | * This type was created in VisualAge. 5 | */ 6 | public interface DebuggingParser { 7 | 8 | 9 | public String getRuleName(int n); 10 | public String getSemPredName(int n); 11 | } 12 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/Event.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | import java.util.EventObject; 4 | 5 | public abstract class Event extends EventObject { 6 | private int type; 7 | 8 | 9 | public Event(Object source) { 10 | super(source); 11 | } 12 | public Event(Object source, int type) { 13 | super(source); 14 | setType(type); 15 | } 16 | public int getType() { 17 | return type; 18 | } 19 | void setType(int type) { 20 | this.type = type; 21 | } 22 | /** This should NOT be called from anyone other than ParserEventSupport! */ 23 | void setValues(int type) { 24 | setType(type); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/GuessingEvent.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public abstract class GuessingEvent extends Event { 4 | private int guessing; 5 | 6 | 7 | public GuessingEvent(Object source) { 8 | super(source); 9 | } 10 | public GuessingEvent(Object source, int type) { 11 | super(source, type); 12 | } 13 | public int getGuessing() { 14 | return guessing; 15 | } 16 | void setGuessing(int guessing) { 17 | this.guessing = guessing; 18 | } 19 | /** This should NOT be called from anyone other than ParserEventSupport! */ 20 | void setValues(int type, int guessing) { 21 | super.setValues(type); 22 | setGuessing(guessing); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/InputBufferAdapter.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | /** A dummy implementation of a CharBufferListener -- this class is not 4 | * meant to be used by itself -- it's meant to be subclassed */ 5 | public abstract class InputBufferAdapter implements InputBufferListener { 6 | 7 | 8 | public void doneParsing(TraceEvent e) { 9 | } 10 | /** 11 | * charConsumed method comment. 12 | */ 13 | public void inputBufferConsume(InputBufferEvent e) { 14 | } 15 | /** 16 | * charLA method comment. 17 | */ 18 | public void inputBufferLA(InputBufferEvent e) { 19 | } 20 | public void inputBufferMark(InputBufferEvent e) {} 21 | public void inputBufferRewind(InputBufferEvent e) {} 22 | public void refresh() { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/InputBufferEvent.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class InputBufferEvent extends Event { 4 | char c; 5 | int lookaheadAmount; // amount of lookahead 6 | public static final int CONSUME = 0; 7 | public static final int LA = 1; 8 | public static final int MARK = 2; 9 | public static final int REWIND = 3; 10 | 11 | 12 | /** 13 | * CharBufferEvent constructor comment. 14 | * @param source java.lang.Object 15 | */ 16 | public InputBufferEvent(Object source) { 17 | super(source); 18 | } 19 | /** 20 | * CharBufferEvent constructor comment. 21 | * @param source java.lang.Object 22 | */ 23 | public InputBufferEvent(Object source, int type, char c, int lookaheadAmount) { 24 | super(source); 25 | setValues(type, c, lookaheadAmount); 26 | } 27 | public char getChar() { 28 | return c; 29 | } 30 | public int getLookaheadAmount() { 31 | return lookaheadAmount; 32 | } 33 | void setChar(char c) { 34 | this.c = c; 35 | } 36 | void setLookaheadAmount(int la) { 37 | this.lookaheadAmount = la; 38 | } 39 | /** This should NOT be called from anyone other than ParserEventSupport! */ 40 | void setValues(int type, char c, int la) { 41 | super.setValues(type); 42 | setChar(c); 43 | setLookaheadAmount(la); 44 | } 45 | public String toString() { 46 | return "CharBufferEvent [" + 47 | (getType()==CONSUME?"CONSUME, ":"LA, ")+ 48 | getChar() + "," + getLookaheadAmount() + "]"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/InputBufferListener.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public interface InputBufferListener extends ListenerBase { 4 | 5 | 6 | public void inputBufferConsume(InputBufferEvent e); 7 | public void inputBufferLA(InputBufferEvent e); 8 | public void inputBufferMark(InputBufferEvent e); 9 | public void inputBufferRewind(InputBufferEvent e); 10 | } 11 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/InputBufferReporter.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class InputBufferReporter implements InputBufferListener { 4 | 5 | 6 | /** 7 | * doneParsing method comment. 8 | */ 9 | public void doneParsing(TraceEvent e) { 10 | } 11 | public void inputBufferChanged(InputBufferEvent e) { 12 | System.out.println(e); 13 | } 14 | /** 15 | * charBufferConsume method comment. 16 | */ 17 | public void inputBufferConsume(InputBufferEvent e) { 18 | System.out.println(e); 19 | } 20 | /** 21 | * charBufferLA method comment. 22 | */ 23 | public void inputBufferLA(InputBufferEvent e) { 24 | System.out.println(e); 25 | } 26 | public void inputBufferMark(InputBufferEvent e) { 27 | System.out.println(e); 28 | } 29 | public void inputBufferRewind(InputBufferEvent e) { 30 | System.out.println(e); 31 | } 32 | /** 33 | * refresh method comment. 34 | */ 35 | public void refresh() { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/ListenerBase.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | import java.util.EventListener; 4 | 5 | public interface ListenerBase extends EventListener { 6 | 7 | 8 | public void doneParsing(TraceEvent e); 9 | public void refresh(); 10 | } 11 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/MessageAdapter.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class MessageAdapter implements MessageListener { 4 | 5 | 6 | public void doneParsing(TraceEvent e) {} 7 | public void refresh() {} 8 | public void reportError(MessageEvent e) {} 9 | public void reportWarning(MessageEvent e) {} 10 | } 11 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/MessageEvent.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class MessageEvent extends Event { 4 | private String text; 5 | public static int WARNING = 0; 6 | public static int ERROR = 1; 7 | 8 | 9 | public MessageEvent(Object source) { 10 | super(source); 11 | } 12 | public MessageEvent(Object source, int type, String text) { 13 | super(source); 14 | setValues(type,text); 15 | } 16 | public String getText() { 17 | return text; 18 | } 19 | void setText(String text) { 20 | this.text = text; 21 | } 22 | /** This should NOT be called from anyone other than ParserEventSupport! */ 23 | void setValues(int type, String text) { 24 | super.setValues(type); 25 | setText(text); 26 | } 27 | public String toString() { 28 | return "ParserMessageEvent [" + 29 | (getType()==WARNING?"warning,":"error,") + 30 | getText() + "]"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/MessageListener.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public interface MessageListener extends ListenerBase { 4 | 5 | 6 | public void reportError(MessageEvent e); 7 | public void reportWarning(MessageEvent e); 8 | } 9 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/NewLineEvent.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class NewLineEvent extends Event { 4 | private int line; 5 | 6 | 7 | public NewLineEvent(Object source) { 8 | super(source); 9 | } 10 | public NewLineEvent(Object source, int line) { 11 | super(source); 12 | setValues(line); 13 | } 14 | public int getLine() { 15 | return line; 16 | } 17 | void setLine(int line) { 18 | this.line = line; 19 | } 20 | /** This should NOT be called from anyone other than ParserEventSupport! */ 21 | void setValues(int line) { 22 | setLine(line); 23 | } 24 | public String toString() { 25 | return "NewLineEvent [" + line + "]"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/NewLineListener.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public interface NewLineListener extends ListenerBase { 4 | 5 | 6 | public void hitNewLine(NewLineEvent e); 7 | } 8 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/ParserAdapter.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class ParserAdapter implements ParserListener { 4 | 5 | 6 | public void doneParsing(TraceEvent e) {} 7 | public void enterRule(TraceEvent e) {} 8 | public void exitRule(TraceEvent e) {} 9 | public void parserConsume(ParserTokenEvent e) {} 10 | public void parserLA(ParserTokenEvent e) {} 11 | public void parserMatch(ParserMatchEvent e) {} 12 | public void parserMatchNot(ParserMatchEvent e) {} 13 | public void parserMismatch(ParserMatchEvent e) {} 14 | public void parserMismatchNot(ParserMatchEvent e) {} 15 | public void refresh() {} 16 | public void reportError(MessageEvent e) {} 17 | public void reportWarning(MessageEvent e) {} 18 | public void semanticPredicateEvaluated(SemanticPredicateEvent e) {} 19 | public void syntacticPredicateFailed(SyntacticPredicateEvent e) {} 20 | public void syntacticPredicateStarted(SyntacticPredicateEvent e) {} 21 | public void syntacticPredicateSucceeded(SyntacticPredicateEvent e) {} 22 | } 23 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/ParserController.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public interface ParserController extends ParserListener { 4 | 5 | 6 | public void checkBreak(); 7 | public void setParserEventSupport(ParserEventSupport p); 8 | } 9 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/ParserListener.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public interface ParserListener extends SemanticPredicateListener, 4 | ParserMatchListener, 5 | MessageListener, 6 | ParserTokenListener, 7 | TraceListener, 8 | SyntacticPredicateListener { 9 | } 10 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/ParserMatchAdapter.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class ParserMatchAdapter implements ParserMatchListener { 4 | 5 | 6 | public void doneParsing(TraceEvent e) {} 7 | public void parserMatch(ParserMatchEvent e) {} 8 | public void parserMatchNot(ParserMatchEvent e) {} 9 | public void parserMismatch(ParserMatchEvent e) {} 10 | public void parserMismatchNot(ParserMatchEvent e) {} 11 | public void refresh() {} 12 | } 13 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/ParserMatchListener.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public interface ParserMatchListener extends ListenerBase { 4 | 5 | 6 | public void parserMatch(ParserMatchEvent e); 7 | public void parserMatchNot(ParserMatchEvent e); 8 | public void parserMismatch(ParserMatchEvent e); 9 | public void parserMismatchNot(ParserMatchEvent e); 10 | } 11 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/ParserReporter.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class ParserReporter extends Tracer implements ParserListener { 4 | 5 | 6 | public void parserConsume(ParserTokenEvent e) { 7 | System.out.println(indent+e); 8 | } 9 | public void parserLA(ParserTokenEvent e) { 10 | System.out.println(indent+e); 11 | } 12 | public void parserMatch(ParserMatchEvent e) { 13 | System.out.println(indent+e); 14 | } 15 | public void parserMatchNot(ParserMatchEvent e) { 16 | System.out.println(indent+e); 17 | } 18 | public void parserMismatch(ParserMatchEvent e) { 19 | System.out.println(indent+e); 20 | } 21 | public void parserMismatchNot(ParserMatchEvent e) { 22 | System.out.println(indent+e); 23 | } 24 | public void reportError(MessageEvent e) { 25 | System.out.println(indent+e); 26 | } 27 | public void reportWarning(MessageEvent e) { 28 | System.out.println(indent+e); 29 | } 30 | public void semanticPredicateEvaluated(SemanticPredicateEvent e) { 31 | System.out.println(indent+e); 32 | } 33 | public void syntacticPredicateFailed(SyntacticPredicateEvent e) { 34 | System.out.println(indent+e); 35 | } 36 | public void syntacticPredicateStarted(SyntacticPredicateEvent e) { 37 | System.out.println(indent+e); 38 | } 39 | public void syntacticPredicateSucceeded(SyntacticPredicateEvent e) { 40 | System.out.println(indent+e); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/ParserTokenAdapter.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class ParserTokenAdapter implements ParserTokenListener { 4 | 5 | 6 | public void doneParsing(TraceEvent e) {} 7 | public void parserConsume(ParserTokenEvent e) {} 8 | public void parserLA(ParserTokenEvent e) {} 9 | public void refresh() {} 10 | } 11 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/ParserTokenEvent.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class ParserTokenEvent extends Event { 4 | private int value; 5 | private int amount; 6 | public static int LA=0; 7 | public static int CONSUME=1; 8 | 9 | 10 | public ParserTokenEvent(Object source) { 11 | super(source); 12 | } 13 | public ParserTokenEvent(Object source, int type, 14 | int amount, int value) { 15 | super(source); 16 | setValues(type,amount,value); 17 | } 18 | public int getAmount() { 19 | return amount; 20 | } 21 | public int getValue() { 22 | return value; 23 | } 24 | void setAmount(int amount) { 25 | this.amount = amount; 26 | } 27 | void setValue(int value) { 28 | this.value = value; 29 | } 30 | /** This should NOT be called from anyone other than ParserEventSupport! */ 31 | void setValues(int type, int amount, int value) { 32 | super.setValues(type); 33 | setAmount(amount); 34 | setValue(value); 35 | } 36 | public String toString() { 37 | if (getType()==LA) 38 | return "ParserTokenEvent [LA," + getAmount() + "," + 39 | getValue() + "]"; 40 | else 41 | return "ParserTokenEvent [consume,1," + 42 | getValue() + "]"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/ParserTokenListener.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public interface ParserTokenListener extends ListenerBase { 4 | 5 | 6 | public void parserConsume(ParserTokenEvent e); 7 | public void parserLA(ParserTokenEvent e); 8 | } 9 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/SemanticPredicateAdapter.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class SemanticPredicateAdapter implements SemanticPredicateListener { 4 | 5 | 6 | public void doneParsing(TraceEvent e) {} 7 | public void refresh() {} 8 | public void semanticPredicateEvaluated(SemanticPredicateEvent e) {} 9 | } 10 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/SemanticPredicateEvent.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class SemanticPredicateEvent extends GuessingEvent { 4 | public static final int VALIDATING=0; 5 | public static final int PREDICTING=1; 6 | private int condition; 7 | private boolean result; 8 | 9 | 10 | public SemanticPredicateEvent(Object source) { 11 | super(source); 12 | } 13 | public SemanticPredicateEvent(Object source, int type) { 14 | super(source, type); 15 | } 16 | public int getCondition() { 17 | return condition; 18 | } 19 | public boolean getResult() { 20 | return result; 21 | } 22 | void setCondition(int condition) { 23 | this.condition = condition; 24 | } 25 | void setResult(boolean result) { 26 | this.result = result; 27 | } 28 | /** This should NOT be called from anyone other than ParserEventSupport! */ 29 | void setValues(int type, int condition, boolean result, int guessing) { 30 | super.setValues(type, guessing); 31 | setCondition(condition); 32 | setResult(result); 33 | } 34 | public String toString() { 35 | return "SemanticPredicateEvent [" + 36 | getCondition() + "," + getResult() + "," + getGuessing() + "]"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/SemanticPredicateListener.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public interface SemanticPredicateListener extends ListenerBase { 4 | 5 | 6 | public void semanticPredicateEvaluated(SemanticPredicateEvent e); 7 | } 8 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/SyntacticPredicateAdapter.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class SyntacticPredicateAdapter implements SyntacticPredicateListener { 4 | 5 | 6 | public void doneParsing(TraceEvent e) {} 7 | public void refresh() {} 8 | public void syntacticPredicateFailed(SyntacticPredicateEvent e) {} 9 | public void syntacticPredicateStarted(SyntacticPredicateEvent e) {} 10 | public void syntacticPredicateSucceeded(SyntacticPredicateEvent e) {} 11 | } 12 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/SyntacticPredicateEvent.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class SyntacticPredicateEvent extends GuessingEvent { 4 | 5 | 6 | public SyntacticPredicateEvent(Object source) { 7 | super(source); 8 | } 9 | public SyntacticPredicateEvent(Object source, int type) { 10 | super(source, type); 11 | } 12 | /** This should NOT be called from anyone other than ParserEventSupport! */ 13 | void setValues(int type, int guessing) { 14 | super.setValues(type, guessing); 15 | } 16 | public String toString() { 17 | return "SyntacticPredicateEvent [" + getGuessing() + "]"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/SyntacticPredicateListener.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public interface SyntacticPredicateListener extends ListenerBase { 4 | 5 | 6 | public void syntacticPredicateFailed(SyntacticPredicateEvent e); 7 | public void syntacticPredicateStarted(SyntacticPredicateEvent e); 8 | public void syntacticPredicateSucceeded(SyntacticPredicateEvent e); 9 | } 10 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/TraceAdapter.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class TraceAdapter implements TraceListener { 4 | 5 | 6 | public void doneParsing(TraceEvent e) {} 7 | public void enterRule(TraceEvent e) {} 8 | public void exitRule(TraceEvent e) {} 9 | public void refresh() {} 10 | } 11 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/TraceEvent.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class TraceEvent extends GuessingEvent { 4 | private int ruleNum; 5 | private int data; 6 | public static int ENTER=0; 7 | public static int EXIT=1; 8 | public static int DONE_PARSING=2; 9 | 10 | 11 | public TraceEvent(Object source) { 12 | super(source); 13 | } 14 | public TraceEvent(Object source, int type, int ruleNum, int guessing, int data) { 15 | super(source); 16 | setValues(type, ruleNum, guessing, data); 17 | } 18 | public int getData() { 19 | return data; 20 | } 21 | public int getRuleNum() { 22 | return ruleNum; 23 | } 24 | void setData(int data) { 25 | this.data = data; 26 | } 27 | void setRuleNum(int ruleNum) { 28 | this.ruleNum = ruleNum; 29 | } 30 | /** This should NOT be called from anyone other than ParserEventSupport! */ 31 | void setValues(int type, int ruleNum, int guessing, int data) { 32 | super.setValues(type, guessing); 33 | setRuleNum(ruleNum); 34 | setData(data); 35 | } 36 | public String toString() { 37 | return "ParserTraceEvent [" + 38 | (getType()==ENTER?"enter,":"exit,") + 39 | getRuleNum() + "," + getGuessing() +"]"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/TraceListener.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public interface TraceListener extends ListenerBase { 4 | 5 | 6 | public void enterRule(TraceEvent e); 7 | public void exitRule(TraceEvent e); 8 | } 9 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/Tracer.java: -------------------------------------------------------------------------------- 1 | package antlr.debug; 2 | 3 | public class Tracer extends TraceAdapter implements TraceListener { 4 | String indent=""; // TBD: should be StringBuffer 5 | 6 | 7 | protected void dedent() { 8 | if (indent.length() < 2) 9 | indent = ""; 10 | else 11 | indent = indent.substring(2); 12 | } 13 | public void enterRule(TraceEvent e) { 14 | System.out.println(indent+e); 15 | indent(); 16 | } 17 | public void exitRule(TraceEvent e) { 18 | dedent(); 19 | System.out.println(indent+e); 20 | } 21 | protected void indent() { 22 | indent += " "; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/debug/misc/JTreeASTPanel.java: -------------------------------------------------------------------------------- 1 | package antlr.debug.misc; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/debug/misc/JTreeASTPanel.java#2 $ 8 | */ 9 | 10 | import java.awt.*; 11 | import javax.swing.*; 12 | import javax.swing.tree.*; 13 | import javax.swing.event.*; 14 | 15 | public class JTreeASTPanel extends JPanel { 16 | JTree tree; 17 | 18 | public JTreeASTPanel(TreeModel tm, TreeSelectionListener listener) { 19 | // use a layout that will stretch tree to panel size 20 | setLayout(new BorderLayout()); 21 | 22 | // Create tree 23 | tree = new JTree(tm); 24 | 25 | // Change line style 26 | tree.putClientProperty("JTree.lineStyle", "Angled"); 27 | 28 | // Add TreeSelectionListener 29 | if (listener != null) 30 | tree.addTreeSelectionListener(listener); 31 | 32 | // Put tree in a scrollable pane's viewport 33 | JScrollPane sp = new JScrollPane(); 34 | sp.getViewport().add(tree); 35 | 36 | add(sp, BorderLayout.CENTER); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/preprocessor/Option.java: -------------------------------------------------------------------------------- 1 | package antlr.preprocessor; 2 | 3 | /* ANTLR Translator Generator 4 | * Project led by Terence Parr at http://www.cs.usfca.edu 5 | * Software rights: http://www.antlr.org/license.html 6 | * 7 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/antlr/preprocessor/Option.java#2 $ 8 | */ 9 | 10 | import antlr.collections.impl.Vector; 11 | 12 | class Option { 13 | protected String name; 14 | protected String rhs; 15 | protected Grammar enclosingGrammar; 16 | 17 | public Option(String n, String rhs, Grammar gr) { 18 | name = n; 19 | this.rhs = rhs; 20 | setEnclosingGrammar(gr); 21 | } 22 | 23 | public Grammar getEnclosingGrammar() { 24 | return enclosingGrammar; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public String getRHS() { 32 | return rhs; 33 | } 34 | 35 | public void setEnclosingGrammar(Grammar g) { 36 | enclosingGrammar = g; 37 | } 38 | 39 | public void setName(String n) { 40 | name = n; 41 | } 42 | 43 | public void setRHS(String rhs) { 44 | this.rhs = rhs; 45 | } 46 | 47 | public String toString() { 48 | return "\t" + name + "=" + rhs; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /third_party/antlr/antlr/preprocessor/PreprocessorTokenTypes.java: -------------------------------------------------------------------------------- 1 | // $ANTLR : "preproc.g" -> "Preprocessor.java"$ 2 | 3 | package antlr.preprocessor; 4 | 5 | public interface PreprocessorTokenTypes { 6 | int EOF = 1; 7 | int NULL_TREE_LOOKAHEAD = 3; 8 | int LITERAL_tokens = 4; 9 | int HEADER_ACTION = 5; 10 | int SUBRULE_BLOCK = 6; 11 | int ACTION = 7; 12 | int LITERAL_class = 8; 13 | int ID = 9; 14 | int LITERAL_extends = 10; 15 | int SEMI = 11; 16 | int TOKENS_SPEC = 12; 17 | int OPTIONS_START = 13; 18 | int ASSIGN_RHS = 14; 19 | int RCURLY = 15; 20 | int LITERAL_protected = 16; 21 | int LITERAL_private = 17; 22 | int LITERAL_public = 18; 23 | int BANG = 19; 24 | int ARG_ACTION = 20; 25 | int LITERAL_returns = 21; 26 | int RULE_BLOCK = 22; 27 | int LITERAL_throws = 23; 28 | int COMMA = 24; 29 | int LITERAL_exception = 25; 30 | int LITERAL_catch = 26; 31 | int ALT = 27; 32 | int ELEMENT = 28; 33 | int LPAREN = 29; 34 | int RPAREN = 30; 35 | int ID_OR_KEYWORD = 31; 36 | int CURLY_BLOCK_SCARF = 32; 37 | int WS = 33; 38 | int NEWLINE = 34; 39 | int COMMENT = 35; 40 | int SL_COMMENT = 36; 41 | int ML_COMMENT = 37; 42 | int CHAR_LITERAL = 38; 43 | int STRING_LITERAL = 39; 44 | int ESC = 40; 45 | int DIGIT = 41; 46 | int XDIGIT = 42; 47 | } 48 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/AUTHORS: -------------------------------------------------------------------------------- 1 | Author: 2 | Peter Wells 3 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/ANTLRException.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_ANTLRException_hpp__ 2 | #define INC_ANTLRException_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/ANTLRException.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | class ANTLR_API ANTLRException 19 | { 20 | public: 21 | /// Create ANTLR base exception without error message 22 | ANTLRException() : text("") 23 | { 24 | } 25 | /// Create ANTLR base exception with error message 26 | ANTLRException(const ANTLR_USE_NAMESPACE(std)string& s) 27 | : text(s) 28 | { 29 | } 30 | virtual ~ANTLRException() throw() 31 | { 32 | } 33 | 34 | /** Return complete error message with line/column number info (if present) 35 | * @note for your own exceptions override this one. Call getMessage from 36 | * here to get the 'clean' error message stored in the text attribute. 37 | */ 38 | virtual ANTLR_USE_NAMESPACE(std)string toString() const 39 | { 40 | return text; 41 | } 42 | 43 | /** Return error message without additional info (if present) 44 | * @note when making your own exceptions classes override toString 45 | * and call in toString getMessage which relays the text attribute 46 | * from here. 47 | */ 48 | virtual ANTLR_USE_NAMESPACE(std)string getMessage() const 49 | { 50 | return text; 51 | } 52 | private: 53 | ANTLR_USE_NAMESPACE(std)string text; 54 | }; 55 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 56 | } 57 | #endif 58 | 59 | #endif //INC_ANTLRException_hpp__ 60 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/ASTArray.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_ASTArray_hpp__ 2 | #define INC_ASTArray_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/ASTArray.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | /** ASTArray is a class that allows ANTLR to 19 | * generate code that can create and initialize an array 20 | * in one expression, like: 21 | * (new ASTArray(3))->add(x)->add(y)->add(z) 22 | */ 23 | class ANTLR_API ASTArray { 24 | public: 25 | int size; // = 0; 26 | ANTLR_USE_NAMESPACE(std)vector array; 27 | 28 | ASTArray(int capacity) 29 | : size(0) 30 | , array(capacity) 31 | { 32 | } 33 | 34 | ASTArray* add(RefAST node) 35 | { 36 | array[size++] = node; 37 | return this; 38 | } 39 | }; 40 | 41 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 42 | } 43 | #endif 44 | 45 | #endif //INC_ASTArray_hpp__ 46 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "headers", 5 | hdrs = glob(["*.hpp"]), 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/CharBuffer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_CharBuffer_hpp__ 2 | #define INC_CharBuffer_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/CharBuffer.hpp#2 $ 9 | */ 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 18 | namespace antlr { 19 | #endif 20 | 21 | /**A Stream of characters fed to the lexer from a InputStream that can 22 | * be rewound via mark()/rewind() methods. 23 | *

24 | * A dynamic array is used to buffer up all the input characters. Normally, 25 | * "k" characters are stored in the buffer. More characters may be stored 26 | * during guess mode (testing syntactic predicate), or when LT(i>k) is 27 | * referenced. 28 | * Consumption of characters is deferred. In other words, reading the next 29 | * character is not done by consume(), but deferred until needed by LA or LT. 30 | *

31 | * 32 | * @see antlr.CharQueue 33 | */ 34 | 35 | class ANTLR_API CharBuffer : public InputBuffer { 36 | public: 37 | /// Create a character buffer 38 | CharBuffer( ANTLR_USE_NAMESPACE(std)istream& input ); 39 | /// Get the next character from the stream 40 | int getChar(); 41 | 42 | protected: 43 | // character source 44 | ANTLR_USE_NAMESPACE(std)istream& input; 45 | 46 | private: 47 | // NOTE: Unimplemented 48 | CharBuffer(const CharBuffer& other); 49 | CharBuffer& operator=(const CharBuffer& other); 50 | }; 51 | 52 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 53 | } 54 | #endif 55 | 56 | #endif //INC_CharBuffer_hpp__ 57 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/CharStreamException.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_CharStreamException_hpp__ 2 | #define INC_CharStreamException_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/CharStreamException.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | class ANTLR_API CharStreamException : public ANTLRException { 19 | public: 20 | CharStreamException(const ANTLR_USE_NAMESPACE(std)string& s) 21 | : ANTLRException(s) {} 22 | ~CharStreamException() throw() {} 23 | }; 24 | 25 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 26 | } 27 | #endif 28 | 29 | #endif //INC_CharStreamException_hpp__ 30 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/CharStreamIOException.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_CharStreamIOException_hpp__ 2 | #define INC_CharStreamIOException_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/CharStreamIOException.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | class ANTLR_API CharStreamIOException : public CharStreamException { 19 | public: 20 | ANTLR_USE_NAMESPACE(std)exception io; 21 | 22 | CharStreamIOException(ANTLR_USE_NAMESPACE(std)exception& e) 23 | : CharStreamException(e.what()), io(e) {} 24 | ~CharStreamIOException() throw() {} 25 | }; 26 | 27 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 28 | } 29 | #endif 30 | 31 | #endif //INC_CharStreamIOException_hpp__ 32 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/CommonHiddenStreamToken.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_CommonHiddenStreamToken_hpp__ 2 | #define INC_CommonHiddenStreamToken_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/CommonHiddenStreamToken.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | class ANTLR_API CommonHiddenStreamToken : public CommonToken { 19 | protected: 20 | RefToken hiddenBefore; 21 | RefToken hiddenAfter; 22 | 23 | public: 24 | CommonHiddenStreamToken(); 25 | CommonHiddenStreamToken(int t, const ANTLR_USE_NAMESPACE(std)string& txt); 26 | CommonHiddenStreamToken(const ANTLR_USE_NAMESPACE(std)string& s); 27 | 28 | RefToken getHiddenAfter(); 29 | RefToken getHiddenBefore(); 30 | 31 | static RefToken factory(); 32 | 33 | void setHiddenAfter(RefToken t); 34 | void setHiddenBefore(RefToken t); 35 | }; 36 | 37 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 38 | } 39 | #endif 40 | 41 | #endif //INC_CommonHiddenStreamToken_hpp__ 42 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/IOException.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_IOException_hpp__ 2 | #define INC_IOException_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id:$ 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 16 | namespace antlr { 17 | #endif 18 | 19 | /** Generic IOException used inside support code. (thrown by XML I/O routs) 20 | * basically this is something I'm using since a lot of compilers don't 21 | * support ios_base::failure. 22 | */ 23 | class ANTLR_API IOException : public ANTLRException 24 | { 25 | public: 26 | ANTLR_USE_NAMESPACE(std)exception io; 27 | 28 | IOException( ANTLR_USE_NAMESPACE(std)exception& e ) 29 | : ANTLRException(e.what()) 30 | { 31 | } 32 | IOException( const ANTLR_USE_NAMESPACE(std)string& mesg ) 33 | : ANTLRException(mesg) 34 | { 35 | } 36 | virtual ~IOException() throw() 37 | { 38 | } 39 | }; 40 | 41 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 42 | } 43 | #endif 44 | 45 | #endif //INC_IOException_hpp__ 46 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/NoViableAltException.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_NoViableAltException_hpp__ 2 | #define INC_NoViableAltException_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/NoViableAltException.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 17 | namespace antlr { 18 | #endif 19 | 20 | class ANTLR_API NoViableAltException : public RecognitionException { 21 | public: 22 | const RefToken token; 23 | const RefAST node; // handles parsing and treeparsing 24 | 25 | NoViableAltException(RefAST t); 26 | NoViableAltException(RefToken t,const ANTLR_USE_NAMESPACE(std)string& fileName_); 27 | 28 | ~NoViableAltException() throw() {} 29 | 30 | /** 31 | * Returns a clean error message (no line number/column information) 32 | */ 33 | ANTLR_USE_NAMESPACE(std)string getMessage() const; 34 | }; 35 | 36 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 37 | } 38 | #endif 39 | 40 | #endif //INC_NoViableAltException_hpp__ 41 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/NoViableAltForCharException.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_NoViableAltForCharException_hpp__ 2 | # define INC_NoViableAltForCharException_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/NoViableAltForCharException.hpp#2 $ 9 | */ 10 | 11 | # include 12 | # include 13 | # include 14 | 15 | # ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 16 | namespace antlr 17 | { 18 | # endif 19 | 20 | class ANTLR_API NoViableAltForCharException : public RecognitionException 21 | { 22 | public: 23 | NoViableAltForCharException(int c, CharScanner* scanner); 24 | NoViableAltForCharException(int c, const ANTLR_USE_NAMESPACE(std)string& fileName_, 25 | int line_, int column_); 26 | 27 | virtual ~NoViableAltForCharException() throw() 28 | { 29 | } 30 | 31 | /// Returns a clean error message (no line number/column information) 32 | ANTLR_USE_NAMESPACE(std)string getMessage() const; 33 | protected: 34 | int foundChar; 35 | }; 36 | 37 | # ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 38 | } 39 | # endif 40 | 41 | #endif //INC_NoViableAltForCharException_hpp__ 42 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/SemanticException.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_SemanticException_hpp__ 2 | #define INC_SemanticException_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/SemanticException.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | class ANTLR_API SemanticException : public RecognitionException { 19 | public: 20 | SemanticException(const ANTLR_USE_NAMESPACE(std)string& s) 21 | : RecognitionException(s) 22 | { 23 | } 24 | SemanticException(const ANTLR_USE_NAMESPACE(std)string& s, 25 | const ANTLR_USE_NAMESPACE(std)string& fileName_, 26 | int line_,int column_) 27 | : RecognitionException(s,fileName_,line_,column_) 28 | { 29 | } 30 | 31 | ~SemanticException() throw() 32 | { 33 | } 34 | }; 35 | 36 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 37 | } 38 | #endif 39 | 40 | #endif //INC_SemanticException_hpp__ 41 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/String.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_String_hpp__ 2 | #define INC_String_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/String.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | ANTLR_API ANTLR_USE_NAMESPACE(std)string operator+( const ANTLR_USE_NAMESPACE(std)string& lhs, const int rhs ); 19 | ANTLR_API ANTLR_USE_NAMESPACE(std)string operator+( const ANTLR_USE_NAMESPACE(std)string& lhs, size_t rhs ); 20 | 21 | ANTLR_API ANTLR_USE_NAMESPACE(std)string charName( int ch ); 22 | 23 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 24 | } 25 | #endif 26 | 27 | #endif //INC_String_hpp__ 28 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/TokenStream.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_TokenStream_hpp__ 2 | #define INC_TokenStream_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/TokenStream.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | /** This interface allows any object to pretend it is a stream 19 | * of tokens. 20 | * @author Terence Parr, MageLang Institute 21 | */ 22 | class ANTLR_API TokenStream { 23 | public: 24 | virtual RefToken nextToken()=0; 25 | virtual ~TokenStream() 26 | { 27 | } 28 | }; 29 | 30 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 31 | } 32 | #endif 33 | 34 | #endif //INC_TokenStream_hpp__ 35 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/TokenStreamBasicFilter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_TokenStreamBasicFilter_hpp__ 2 | #define INC_TokenStreamBasicFilter_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/TokenStreamBasicFilter.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 16 | namespace antlr { 17 | #endif 18 | 19 | /** This object is a TokenStream that passes through all 20 | * tokens except for those that you tell it to discard. 21 | * There is no buffering of the tokens. 22 | */ 23 | class ANTLR_API TokenStreamBasicFilter : public TokenStream { 24 | /** The set of token types to discard */ 25 | protected: 26 | BitSet discardMask; 27 | 28 | /** The input stream */ 29 | protected: 30 | TokenStream* input; 31 | 32 | public: 33 | TokenStreamBasicFilter(TokenStream& input_); 34 | 35 | void discard(int ttype); 36 | 37 | void discard(const BitSet& mask); 38 | 39 | RefToken nextToken(); 40 | }; 41 | 42 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 43 | } 44 | #endif 45 | 46 | #endif //INC_TokenStreamBasicFilter_hpp__ 47 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/TokenStreamException.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_TokenStreamException_hpp__ 2 | #define INC_TokenStreamException_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/TokenStreamException.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | /** Baseclass for exceptions thrown by classes implementing the TokenStream 19 | * interface. 20 | * @see TokenStream 21 | */ 22 | class ANTLR_API TokenStreamException : public ANTLRException { 23 | public: 24 | TokenStreamException() 25 | : ANTLRException() 26 | { 27 | } 28 | TokenStreamException(const ANTLR_USE_NAMESPACE(std)string& s) 29 | : ANTLRException(s) 30 | { 31 | } 32 | virtual ~TokenStreamException() throw() 33 | { 34 | } 35 | }; 36 | 37 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 38 | } 39 | #endif 40 | 41 | #endif //INC_TokenStreamException_hpp__ 42 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/TokenStreamIOException.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_TokenStreamIOException_hpp__ 2 | #define INC_TokenStreamIOException_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/TokenStreamIOException.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | class TokenStreamIOException : public TokenStreamException { 19 | public: 20 | TokenStreamIOException() 21 | : TokenStreamException() 22 | { 23 | } 24 | TokenStreamIOException(const ANTLR_USE_NAMESPACE(std)exception& e) 25 | : TokenStreamException(e.what()) 26 | , io(e) 27 | { 28 | } 29 | ~TokenStreamIOException() throw() 30 | { 31 | } 32 | private: 33 | ANTLR_USE_NAMESPACE(std)exception io; 34 | }; 35 | 36 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 37 | } 38 | #endif 39 | 40 | #endif //INC_TokenStreamIOException_hpp__ 41 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/TokenStreamRecognitionException.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_TokenStreamRecognitionException_hpp__ 2 | #define INC_TokenStreamRecognitionException_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/TokenStreamRecognitionException.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | /** Exception thrown from generated lexers when there's no default error 19 | * handler specified. 20 | * @see TokenStream 21 | */ 22 | class TokenStreamRecognitionException : public TokenStreamException { 23 | public: 24 | TokenStreamRecognitionException(RecognitionException& re) 25 | : TokenStreamException(re.getMessage()) 26 | , recog(re) 27 | { 28 | } 29 | virtual ~TokenStreamRecognitionException() throw() 30 | { 31 | } 32 | virtual ANTLR_USE_NAMESPACE(std)string toString() const 33 | { 34 | return recog.getFileLineColumnString()+getMessage(); 35 | } 36 | 37 | virtual ANTLR_USE_NAMESPACE(std)string getFilename() const throw() 38 | { 39 | return recog.getFilename(); 40 | } 41 | virtual int getLine() const throw() 42 | { 43 | return recog.getLine(); 44 | } 45 | virtual int getColumn() const throw() 46 | { 47 | return recog.getColumn(); 48 | } 49 | private: 50 | RecognitionException recog; 51 | }; 52 | 53 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 54 | } 55 | #endif 56 | 57 | #endif //INC_TokenStreamRecognitionException_hpp__ 58 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/TokenStreamRetryException.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_TokenStreamRetryException_hpp__ 2 | #define INC_TokenStreamRetryException_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/TokenStreamRetryException.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | class TokenStreamRetryException : public TokenStreamException { 19 | public: 20 | TokenStreamRetryException() {} 21 | ~TokenStreamRetryException() throw() {} 22 | }; 23 | 24 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 25 | } 26 | #endif 27 | 28 | #endif //INC_TokenStreamRetryException_hpp__ 29 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/antlr/TreeParserSharedInputState.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INC_TreeParserSharedInputState_hpp__ 2 | #define INC_TreeParserSharedInputState_hpp__ 3 | 4 | /* ANTLR Translator Generator 5 | * Project led by Terence Parr at http://www.jGuru.com 6 | * Software rights: http://www.antlr.org/license.html 7 | * 8 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/TreeParserSharedInputState.hpp#2 $ 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 15 | namespace antlr { 16 | #endif 17 | 18 | /** This object contains the data associated with an 19 | * input AST. Multiple parsers 20 | * share a single TreeParserSharedInputState to parse 21 | * the same tree or to have the parser walk multiple 22 | * trees. 23 | */ 24 | class ANTLR_API TreeParserInputState { 25 | public: 26 | TreeParserInputState() : guessing(0) {} 27 | virtual ~TreeParserInputState() {} 28 | 29 | public: 30 | /** Are we guessing (guessing>0)? */ 31 | int guessing; //= 0; 32 | 33 | private: 34 | // we don't want these: 35 | TreeParserInputState(const TreeParserInputState&); 36 | TreeParserInputState& operator=(const TreeParserInputState&); 37 | }; 38 | 39 | typedef RefCount TreeParserSharedInputState; 40 | 41 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 42 | } 43 | #endif 44 | 45 | #endif //INC_TreeParserSharedInputState_hpp__ 46 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/ASTRefCount.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 4 | * 5 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/ASTRefCount.cpp#2 $ 6 | */ 7 | #include "antlr/ASTRefCount.hpp" 8 | #include "antlr/AST.hpp" 9 | 10 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 11 | namespace antlr { 12 | #endif 13 | 14 | ASTRef::ASTRef(AST* p) 15 | : ptr(p), count(1) 16 | { 17 | if (p && !p->ref) 18 | p->ref = this; 19 | } 20 | 21 | ASTRef::~ASTRef() 22 | { 23 | delete ptr; 24 | } 25 | 26 | ASTRef* ASTRef::getRef(const AST* p) 27 | { 28 | if (p) { 29 | AST* pp = const_cast(p); 30 | if (pp->ref) 31 | return pp->ref->increment(); 32 | else 33 | return new ASTRef(pp); 34 | } else 35 | return 0; 36 | } 37 | 38 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 39 | } 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "antlr", 5 | srcs = [ 6 | "ANTLRUtil.cpp", 7 | "ASTFactory.cpp", 8 | "ASTNULLType.cpp", 9 | "ASTRefCount.cpp", 10 | "BaseAST.cpp", 11 | "BitSet.cpp", 12 | "CharBuffer.cpp", 13 | "CharScanner.cpp", 14 | "CommonAST.cpp", 15 | "CommonASTWithHiddenTokens.cpp", 16 | "CommonHiddenStreamToken.cpp", 17 | "CommonToken.cpp", 18 | "InputBuffer.cpp", 19 | "LLkParser.cpp", 20 | "MismatchedCharException.cpp", 21 | "MismatchedTokenException.cpp", 22 | "NoViableAltException.cpp", 23 | "NoViableAltForCharException.cpp", 24 | "Parser.cpp", 25 | "RecognitionException.cpp", 26 | "String.cpp", 27 | "Token.cpp", 28 | "TokenBuffer.cpp", 29 | "TokenRefCount.cpp", 30 | "TokenStreamBasicFilter.cpp", 31 | "TokenStreamHiddenTokenFilter.cpp", 32 | "TokenStreamRewriteEngine.cpp", 33 | "TokenStreamSelector.cpp", 34 | "TreeParser.cpp", 35 | ], 36 | copts = ["-Ithird_party/antlr/lib/cpp"], 37 | deps = [ 38 | "//third_party/antlr/lib/cpp/antlr:headers", 39 | ] 40 | ) 41 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/BitSet.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 4 | * 5 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/BitSet.cpp#2 $ 6 | */ 7 | #include "antlr/BitSet.hpp" 8 | #include 9 | 10 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 11 | namespace antlr { 12 | #endif 13 | 14 | BitSet::BitSet(unsigned int nbits) 15 | : storage(nbits) 16 | { 17 | for (unsigned int i = 0; i < nbits ; i++ ) 18 | storage[i] = false; 19 | } 20 | 21 | BitSet::BitSet( const unsigned long* bits_, unsigned int nlongs ) 22 | : storage(nlongs*32) 23 | { 24 | for ( unsigned int i = 0 ; i < (nlongs * 32); i++) 25 | storage[i] = (bits_[i>>5] & (1UL << (i&31))) ? true : false; 26 | } 27 | 28 | BitSet::~BitSet() 29 | { 30 | } 31 | 32 | void BitSet::add(unsigned int el) 33 | { 34 | if( el >= storage.size() ) 35 | storage.resize( el+1, false ); 36 | 37 | storage[el] = true; 38 | } 39 | 40 | bool BitSet::member(unsigned int el) const 41 | { 42 | if ( el >= storage.size()) 43 | return false; 44 | 45 | return storage[el]; 46 | } 47 | 48 | ANTLR_USE_NAMESPACE(std)vector BitSet::toArray() const 49 | { 50 | ANTLR_USE_NAMESPACE(std)vector elems; 51 | for (unsigned int i = 0; i < storage.size(); i++) 52 | { 53 | if (storage[i]) 54 | elems.push_back(i); 55 | } 56 | 57 | return elems; 58 | } 59 | 60 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 61 | } 62 | #endif 63 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/CharBuffer.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 4 | * 5 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/CharBuffer.cpp#2 $ 6 | */ 7 | 8 | #include "antlr/CharBuffer.hpp" 9 | #include 10 | 11 | //#include 12 | 13 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 14 | namespace antlr { 15 | #endif 16 | 17 | /* RK: Per default istream does not throw exceptions. This can be 18 | * enabled with: 19 | * stream.exceptions(ios_base::badbit|ios_base::failbit|ios_base::eofbit); 20 | * 21 | * We could try catching the bad/fail stuff. But handling eof via this is 22 | * not a good idea. EOF is best handled as a 'normal' character. 23 | * 24 | * So this does not work yet with gcc... Comment it until I get to a platform 25 | * that does.. 26 | */ 27 | 28 | /** Create a character buffer. Enable fail and bad exceptions, if supported 29 | * by platform. */ 30 | CharBuffer::CharBuffer(ANTLR_USE_NAMESPACE(std)istream& input_) 31 | : input(input_) 32 | { 33 | // input.exceptions(ANTLR_USE_NAMESPACE(std)ios_base::badbit| 34 | // ANTLR_USE_NAMESPACE(std)ios_base::failbit); 35 | } 36 | 37 | /** Get the next character from the stream. May throw CharStreamIOException 38 | * when something bad happens (not EOF) (if supported by platform). 39 | */ 40 | int CharBuffer::getChar() 41 | { 42 | // try { 43 | return input.get(); 44 | // } 45 | // catch (ANTLR_USE_NAMESPACE(std)ios_base::failure& e) { 46 | // throw CharStreamIOException(e); 47 | // } 48 | } 49 | 50 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/CommonAST.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 4 | * 5 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/CommonAST.cpp#2 $ 6 | */ 7 | #include "antlr/config.hpp" 8 | 9 | #include 10 | #include 11 | 12 | #include "antlr/CommonAST.hpp" 13 | #include "antlr/ANTLRUtil.hpp" 14 | 15 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 16 | namespace antlr { 17 | #endif 18 | 19 | const char* const CommonAST::TYPE_NAME = "CommonAST"; 20 | 21 | #ifdef ANTLR_SUPPORT_XML 22 | void CommonAST::initialize( ANTLR_USE_NAMESPACE(std)istream& in ) 23 | { 24 | ANTLR_USE_NAMESPACE(std)string t1, t2, text; 25 | 26 | // text 27 | read_AttributeNValue( in, t1, text ); 28 | 29 | read_AttributeNValue( in, t1, t2 ); 30 | #ifdef ANTLR_ATOI_IN_STD 31 | int type = ANTLR_USE_NAMESPACE(std)atoi(t2.c_str()); 32 | #else 33 | int type = atoi(t2.c_str()); 34 | #endif 35 | 36 | // initialize first part of AST. 37 | this->initialize( type, text ); 38 | } 39 | #endif 40 | 41 | RefAST CommonAST::factory() 42 | { 43 | return RefAST(new CommonAST); 44 | } 45 | 46 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 47 | } 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/CommonHiddenStreamToken.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 4 | * 5 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/CommonHiddenStreamToken.cpp#2 $ 6 | */ 7 | #include "antlr/CommonHiddenStreamToken.hpp" 8 | 9 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 10 | namespace antlr { 11 | #endif 12 | 13 | CommonHiddenStreamToken::CommonHiddenStreamToken() 14 | : CommonToken() 15 | { 16 | } 17 | 18 | CommonHiddenStreamToken::CommonHiddenStreamToken(int t, const ANTLR_USE_NAMESPACE(std)string& txt) 19 | : CommonToken(t,txt) 20 | { 21 | } 22 | 23 | CommonHiddenStreamToken::CommonHiddenStreamToken(const ANTLR_USE_NAMESPACE(std)string& s) 24 | : CommonToken(s) 25 | { 26 | } 27 | 28 | RefToken CommonHiddenStreamToken::getHiddenAfter() 29 | { 30 | return hiddenAfter; 31 | } 32 | 33 | RefToken CommonHiddenStreamToken::getHiddenBefore() 34 | { 35 | return hiddenBefore; 36 | } 37 | 38 | RefToken CommonHiddenStreamToken::factory() 39 | { 40 | return RefToken(new CommonHiddenStreamToken); 41 | } 42 | 43 | void CommonHiddenStreamToken::setHiddenAfter(RefToken t) 44 | { 45 | hiddenAfter = t; 46 | } 47 | 48 | void CommonHiddenStreamToken::setHiddenBefore(RefToken t) 49 | { 50 | hiddenBefore = t; 51 | } 52 | 53 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 54 | } 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/CommonToken.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 4 | * 5 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/CommonToken.cpp#2 $ 6 | */ 7 | 8 | #include "antlr/CommonToken.hpp" 9 | #include "antlr/String.hpp" 10 | 11 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 12 | namespace antlr { 13 | #endif 14 | 15 | CommonToken::CommonToken() : Token(), line(1), col(1), text("") 16 | {} 17 | 18 | CommonToken::CommonToken(int t, const ANTLR_USE_NAMESPACE(std)string& txt) 19 | : Token(t) 20 | , line(1) 21 | , col(1) 22 | , text(txt) 23 | {} 24 | 25 | CommonToken::CommonToken(const ANTLR_USE_NAMESPACE(std)string& s) 26 | : Token() 27 | , line(1) 28 | , col(1) 29 | , text(s) 30 | {} 31 | 32 | ANTLR_USE_NAMESPACE(std)string CommonToken::toString() const 33 | { 34 | return "[\""+getText()+"\",<"+getType()+">,line="+getLine()+",column="+getColumn()+"]"; 35 | } 36 | 37 | RefToken CommonToken::factory() 38 | { 39 | return RefToken(new CommonToken); 40 | } 41 | 42 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 43 | } 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/NoViableAltException.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 4 | * 5 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/NoViableAltException.cpp#2 $ 6 | */ 7 | 8 | #include "antlr/NoViableAltException.hpp" 9 | #include "antlr/String.hpp" 10 | 11 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 12 | namespace antlr { 13 | #endif 14 | 15 | ANTLR_USING_NAMESPACE(std) 16 | 17 | NoViableAltException::NoViableAltException(RefAST t) 18 | : RecognitionException("NoViableAlt","",-1,-1), 19 | token(0), node(t) 20 | { 21 | } 22 | 23 | NoViableAltException::NoViableAltException( 24 | RefToken t, 25 | const ANTLR_USE_NAMESPACE(std)string& fileName_ 26 | ) : RecognitionException("NoViableAlt",fileName_,t->getLine(),t->getColumn()), 27 | token(t), node(nullASTptr) 28 | { 29 | } 30 | 31 | ANTLR_USE_NAMESPACE(std)string NoViableAltException::getMessage() const 32 | { 33 | if (token) 34 | { 35 | if( token->getType() == Token::EOF_TYPE ) 36 | return string("unexpected end of file"); 37 | else if( token->getType() == Token::NULL_TREE_LOOKAHEAD ) 38 | return string("unexpected end of tree"); 39 | else 40 | return string("unexpected token: ")+token->getText(); 41 | } 42 | 43 | // must a tree parser error if token==null 44 | if (!node) 45 | return "unexpected end of subtree"; 46 | 47 | return string("unexpected AST node: ")+node->toString(); 48 | } 49 | 50 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/NoViableAltForCharException.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 4 | * 5 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/NoViableAltForCharException.cpp#2 $ 6 | */ 7 | 8 | #include "antlr/NoViableAltForCharException.hpp" 9 | #include "antlr/String.hpp" 10 | 11 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 12 | namespace antlr { 13 | #endif 14 | 15 | NoViableAltForCharException::NoViableAltForCharException(int c, CharScanner* scanner) 16 | : RecognitionException("NoViableAlt", 17 | scanner->getFilename(), 18 | scanner->getLine(),scanner->getColumn()), 19 | foundChar(c) 20 | { 21 | } 22 | 23 | NoViableAltForCharException::NoViableAltForCharException( 24 | int c, 25 | const ANTLR_USE_NAMESPACE(std)string& fileName_, 26 | int line_, int column_) 27 | : RecognitionException("NoViableAlt",fileName_,line_,column_), 28 | foundChar(c) 29 | { 30 | } 31 | 32 | ANTLR_USE_NAMESPACE(std)string NoViableAltForCharException::getMessage() const 33 | { 34 | return ANTLR_USE_NAMESPACE(std)string("unexpected char: ")+charName(foundChar); 35 | } 36 | 37 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/Token.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 4 | * 5 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/Token.cpp#2 $ 6 | */ 7 | 8 | #include "antlr/Token.hpp" 9 | #include "antlr/String.hpp" 10 | 11 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 12 | namespace antlr { 13 | #endif 14 | 15 | int Token::getColumn() const 16 | { 17 | return 0; 18 | } 19 | 20 | int Token::getLine() const 21 | { 22 | return 0; 23 | } 24 | 25 | ANTLR_USE_NAMESPACE(std)string Token::getText() const 26 | { 27 | return ""; 28 | } 29 | 30 | int Token::getType() const 31 | { 32 | return type; 33 | } 34 | 35 | void Token::setColumn(int) 36 | { 37 | } 38 | 39 | void Token::setLine(int) 40 | { 41 | } 42 | 43 | void Token::setText(const ANTLR_USE_NAMESPACE(std)string&) 44 | { 45 | } 46 | 47 | void Token::setType(int t) 48 | { 49 | type = t; 50 | } 51 | 52 | void Token::setFilename(const ANTLR_USE_NAMESPACE(std)string&) 53 | { 54 | } 55 | 56 | ANTLR_USE_NAMESPACE(std)string emptyString(""); 57 | 58 | const ANTLR_USE_NAMESPACE(std)string& Token::getFilename() const 59 | { 60 | return emptyString; 61 | } 62 | 63 | ANTLR_USE_NAMESPACE(std)string Token::toString() const 64 | { 65 | return "[\""+getText()+"\",<"+type+">]"; 66 | } 67 | 68 | ANTLR_API RefToken nullToken; 69 | 70 | #ifndef NO_STATIC_CONSTS 71 | const int Token::MIN_USER_TYPE; 72 | const int Token::NULL_TREE_LOOKAHEAD; 73 | const int Token::INVALID_TYPE; 74 | const int Token::EOF_TYPE; 75 | const int Token::SKIP; 76 | #endif 77 | 78 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 79 | } 80 | #endif 81 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/TokenRefCount.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 4 | * 5 | * $Id:$ 6 | */ 7 | #include "antlr/TokenRefCount.hpp" 8 | #include "antlr/Token.hpp" 9 | 10 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 11 | namespace antlr { 12 | #endif 13 | 14 | TokenRef::TokenRef(Token* p) 15 | : ptr(p), count(1) 16 | { 17 | if (p && !p->ref) 18 | p->ref = this; 19 | } 20 | 21 | TokenRef::~TokenRef() 22 | { 23 | delete ptr; 24 | } 25 | 26 | TokenRef* TokenRef::getRef(const Token* p) 27 | { 28 | if (p) { 29 | Token* pp = const_cast(p); 30 | if (pp->ref) 31 | return pp->ref->increment(); 32 | else 33 | return new TokenRef(pp); 34 | } else 35 | return 0; 36 | } 37 | 38 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 39 | } 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /third_party/antlr/lib/cpp/src/TokenStreamBasicFilter.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 4 | * 5 | * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/TokenStreamBasicFilter.cpp#2 $ 6 | */ 7 | #include "antlr/TokenStreamBasicFilter.hpp" 8 | 9 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 10 | namespace antlr { 11 | #endif 12 | 13 | /** This object is a TokenStream that passes through all 14 | * tokens except for those that you tell it to discard. 15 | * There is no buffering of the tokens. 16 | */ 17 | TokenStreamBasicFilter::TokenStreamBasicFilter(TokenStream& input_) 18 | : input(&input_) 19 | { 20 | } 21 | 22 | void TokenStreamBasicFilter::discard(int ttype) 23 | { 24 | discardMask.add(ttype); 25 | } 26 | 27 | void TokenStreamBasicFilter::discard(const BitSet& mask) 28 | { 29 | discardMask = mask; 30 | } 31 | 32 | RefToken TokenStreamBasicFilter::nextToken() 33 | { 34 | RefToken tok = input->nextToken(); 35 | while ( tok && discardMask.member(tok->getType()) ) { 36 | tok = input->nextToken(); 37 | } 38 | return tok; 39 | } 40 | 41 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 42 | } 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /third_party/jar_splitter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | com.google.devtools.cdbg.debuglets.java 7 | cdbg_jar_splitter_tool 8 | SNAPSHOT 9 | 10 | 11 | target 12 | 13 | 14 | 15 | maven-compiler-plugin 16 | 3.0 17 | 18 | 1.7 19 | 1.7 20 | 21 | 22 | 23 | 24 | maven-assembly-plugin 25 | 2.5.2 26 | 27 | 28 | 29 | com.google.devtools.cdbg.debuglets.java.JarSplitterMain 30 | 31 | 32 | 33 | jar-with-dependencies 34 | 35 | 36 | 37 | 38 | cdbg_jar_splitter_tool_assembly 39 | package 40 | 41 | single 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | --------------------------------------------------------------------------------