diff --git a/packages/cxx-gen-ast/src/kwgen.ts b/packages/cxx-gen-ast/src/kwgen.ts index 9f3ae17b..f1e37998 100644 --- a/packages/cxx-gen-ast/src/kwgen.ts +++ b/packages/cxx-gen-ast/src/kwgen.ts @@ -25,13 +25,17 @@ export default function kwgen(options: Options) { } = options; let out: string[] = []; - const emit = (s: string) => out.push(s); + const emit = (s: string = "") => out.push(s); if (copyright !== undefined) { emit("// Generated file by: kwgen.ts"); emit(copyright); } + emit(); + emit("#pragma once"); + emit(); + const keywordsByLength = Map.groupBy(keywords, (s) => s.length); const lengths = Array.from(keywordsByLength.keys()); diff --git a/src/parser/cxx/literals.h b/src/parser/cxx/literals.h index 79eb43af..939a9038 100644 --- a/src/parser/cxx/literals.h +++ b/src/parser/cxx/literals.h @@ -18,6 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#pragma once + #include #include diff --git a/src/parser/cxx/literals_fwd.h b/src/parser/cxx/literals_fwd.h index cb2a26e8..aea78271 100644 --- a/src/parser/cxx/literals_fwd.h +++ b/src/parser/cxx/literals_fwd.h @@ -18,6 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#pragma once + #include namespace cxx { diff --git a/src/parser/cxx/name_lookup.h b/src/parser/cxx/name_lookup.h index 73103366..c6e06700 100644 --- a/src/parser/cxx/name_lookup.h +++ b/src/parser/cxx/name_lookup.h @@ -18,6 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#pragma once + #include #include #include diff --git a/src/parser/cxx/private/c_keywords-priv.h b/src/parser/cxx/private/c_keywords-priv.h index a9dfd092..6af5d0da 100644 --- a/src/parser/cxx/private/c_keywords-priv.h +++ b/src/parser/cxx/private/c_keywords-priv.h @@ -19,6 +19,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#pragma once + static inline auto classifyC2(const char* s) -> cxx::TokenKind { if (s[0] == 'd') { if (s[1] == 'o') { diff --git a/src/parser/cxx/private/keywords-priv.h b/src/parser/cxx/private/keywords-priv.h index e7001b0c..3337b860 100644 --- a/src/parser/cxx/private/keywords-priv.h +++ b/src/parser/cxx/private/keywords-priv.h @@ -19,6 +19,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#pragma once + static inline auto classify2(const char* s) -> cxx::TokenKind { if (s[0] == 'd') { if (s[1] == 'o') { diff --git a/src/parser/cxx/private/pp_directives-priv.h b/src/parser/cxx/private/pp_directives-priv.h index f6cbc0b8..865cef53 100644 --- a/src/parser/cxx/private/pp_directives-priv.h +++ b/src/parser/cxx/private/pp_directives-priv.h @@ -19,6 +19,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#pragma once + enum class PreprocessorDirectiveKind { T_IDENTIFIER, T_DEFINE, diff --git a/src/parser/cxx/symbol_instantiation.h b/src/parser/cxx/symbol_instantiation.h index c09d9cf2..e5c4467f 100644 --- a/src/parser/cxx/symbol_instantiation.h +++ b/src/parser/cxx/symbol_instantiation.h @@ -18,6 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#pragma once + #include #include #include