|
| 1 | +// Copyright (c) 2025 Roberto Raggi <[email protected]> |
| 2 | +// |
| 3 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 | +// of this software and associated documentation files (the "Software"), to deal |
| 5 | +// in the Software without restriction, including without limitation the rights |
| 6 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 | +// copies of the Software, and to permit persons to whom the Software is |
| 8 | +// furnished to do so, subject to the following conditions: |
| 9 | +// |
| 10 | +// The above copyright notice and this permission notice shall be included in |
| 11 | +// all copies or substantial portions of the Software. |
| 12 | +// |
| 13 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 19 | +// SOFTWARE. |
| 20 | + |
| 21 | +import * as tokens from "./tokens.ts"; |
| 22 | +import kwgen from "./kwgen.ts"; |
| 23 | +import { cpy_header } from "./cpy_header.ts"; |
| 24 | + |
| 25 | +export function gen_c_keywords_kwgen({ output }: { output: string }) { |
| 26 | + const keywords: string[] = []; |
| 27 | + |
| 28 | + keywords.push(...tokens.C_KEYWORDS); |
| 29 | + |
| 30 | + Object.entries(tokens.C_TOKEN_ALIASES).forEach(([tk]) => { |
| 31 | + keywords.push(tk); |
| 32 | + }); |
| 33 | + |
| 34 | + kwgen({ |
| 35 | + copyright: cpy_header, |
| 36 | + output, |
| 37 | + keywords, |
| 38 | + tokenPrefix: "cxx::TokenKind::T_", |
| 39 | + tokenType: "cxx::TokenKind", |
| 40 | + toUpper: true, |
| 41 | + noEnums: true, |
| 42 | + defaultToken: "cxx::TokenKind::T_IDENTIFIER", |
| 43 | + classifier: "classifyC", |
| 44 | + }); |
| 45 | +} |
0 commit comments