1 /* 2 * Copyright (C) 2024 The Android Open Source Project 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 SRC_TRACE_PROCESSOR_PERFETTO_SQL_PREPROCESSOR_PREPROCESSOR_GRAMMAR_INTERFACE_H_ 18 #define SRC_TRACE_PROCESSOR_PERFETTO_SQL_PREPROCESSOR_PREPROCESSOR_GRAMMAR_INTERFACE_H_ 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #include <stddef.h> 25 #include <stdio.h> 26 27 #include "src/trace_processor/perfetto_sql/preprocessor/preprocessor_grammar.h" 28 29 #undef NDEBUG 30 31 #ifdef __cplusplus 32 namespace perfetto::trace_processor { 33 namespace { 34 #endif 35 36 struct PreprocessorGrammarState; 37 38 struct PreprocessorGrammarToken { 39 const char* ptr; 40 size_t n; 41 int major; 42 }; 43 44 struct PreprocessorGrammarTokenBounds { 45 struct PreprocessorGrammarToken start; 46 struct PreprocessorGrammarToken end; 47 }; 48 49 struct PreprocessorGrammarApplyList; 50 51 void* PreprocessorGrammarParseAlloc(void* (*)(size_t), 52 struct PreprocessorGrammarState*); 53 void PreprocessorGrammarParse(void* parser, 54 int, 55 struct PreprocessorGrammarToken); 56 void PreprocessorGrammarParseFree(void* parser, void (*)(void*)); 57 void PreprocessorGrammarParseTrace(FILE*, char*); 58 59 void OnPreprocessorSyntaxError(struct PreprocessorGrammarState*, 60 struct PreprocessorGrammarToken*); 61 void OnPreprocessorApply(struct PreprocessorGrammarState*, 62 struct PreprocessorGrammarToken* name, 63 struct PreprocessorGrammarToken* join, 64 struct PreprocessorGrammarToken* prefix, 65 struct PreprocessorGrammarApplyList*, 66 struct PreprocessorGrammarApplyList*); 67 void OnPreprocessorVariable(struct PreprocessorGrammarState*, 68 struct PreprocessorGrammarToken* var); 69 void OnPreprocessorMacroId(struct PreprocessorGrammarState*, 70 struct PreprocessorGrammarToken* name); 71 void OnPreprocessorMacroArg(struct PreprocessorGrammarState*, 72 struct PreprocessorGrammarTokenBounds*); 73 void OnPreprocessorMacroEnd(struct PreprocessorGrammarState*, 74 struct PreprocessorGrammarToken* name, 75 struct PreprocessorGrammarToken* rp); 76 void OnPreprocessorEnd(struct PreprocessorGrammarState*); 77 78 struct PreprocessorGrammarApplyList* OnPreprocessorCreateApplyList(); 79 struct PreprocessorGrammarApplyList* OnPreprocessorAppendApplyList( 80 struct PreprocessorGrammarApplyList*, 81 struct PreprocessorGrammarTokenBounds*); 82 void OnPreprocessorFreeApplyList(struct PreprocessorGrammarState*, 83 struct PreprocessorGrammarApplyList*); 84 85 #ifdef __cplusplus 86 } 87 } 88 } 89 #endif 90 91 #endif // SRC_TRACE_PROCESSOR_PERFETTO_SQL_PREPROCESSOR_PREPROCESSOR_GRAMMAR_INTERFACE_H_ 92