|
| 1 | +/****************************************************************************** |
| 2 | + * This file was generated by langium-cli 3.2.0. |
| 3 | + * DO NOT EDIT MANUALLY! |
| 4 | + ******************************************************************************/ |
| 5 | + |
| 6 | +/* eslint-disable */ |
| 7 | +import type { AstNode, ReferenceInfo, TypeMetaData } from 'langium'; |
| 8 | +import { AbstractAstReflection } from 'langium'; |
| 9 | + |
| 10 | +export const LimbooleTerminals = { |
| 11 | + VAR: /([a-zA-Z0-9_\-\.\[\]\$\@]*[a-zA-Z0-9_\.\[\]\$\@])/, |
| 12 | + SL_COMMENT: /%[^\n\r]*/, |
| 13 | + WS: /\s+/, |
| 14 | +}; |
| 15 | + |
| 16 | +export type LimbooleTerminalNames = keyof typeof LimbooleTerminals; |
| 17 | + |
| 18 | +export type LimbooleKeywordNames = |
| 19 | + | "!" |
| 20 | + | "&" |
| 21 | + | "(" |
| 22 | + | ")" |
| 23 | + | "->" |
| 24 | + | "<-" |
| 25 | + | "<->" |
| 26 | + | "|"; |
| 27 | + |
| 28 | +export type LimbooleTokenNames = LimbooleTerminalNames | LimbooleKeywordNames; |
| 29 | + |
| 30 | +export interface Expr extends AstNode { |
| 31 | + readonly $type: 'And' | 'Expr' | 'Iff' | 'Implies' | 'Or'; |
| 32 | + var: string; |
| 33 | +} |
| 34 | + |
| 35 | +export const Expr = 'Expr'; |
| 36 | + |
| 37 | +export function isExpr(item: unknown): item is Expr { |
| 38 | + return reflection.isInstance(item, Expr); |
| 39 | +} |
| 40 | + |
| 41 | +export interface And extends Expr { |
| 42 | + readonly $type: 'And'; |
| 43 | + left: Expr; |
| 44 | + right: Expr; |
| 45 | +} |
| 46 | + |
| 47 | +export const And = 'And'; |
| 48 | + |
| 49 | +export function isAnd(item: unknown): item is And { |
| 50 | + return reflection.isInstance(item, And); |
| 51 | +} |
| 52 | + |
| 53 | +export interface Iff extends Expr { |
| 54 | + readonly $type: 'Iff'; |
| 55 | + left: Expr; |
| 56 | + right: Expr; |
| 57 | +} |
| 58 | + |
| 59 | +export const Iff = 'Iff'; |
| 60 | + |
| 61 | +export function isIff(item: unknown): item is Iff { |
| 62 | + return reflection.isInstance(item, Iff); |
| 63 | +} |
| 64 | + |
| 65 | +export interface Implies extends Expr { |
| 66 | + readonly $type: 'Implies'; |
| 67 | + left: Expr; |
| 68 | + right: Expr; |
| 69 | +} |
| 70 | + |
| 71 | +export const Implies = 'Implies'; |
| 72 | + |
| 73 | +export function isImplies(item: unknown): item is Implies { |
| 74 | + return reflection.isInstance(item, Implies); |
| 75 | +} |
| 76 | + |
| 77 | +export interface Or extends Expr { |
| 78 | + readonly $type: 'Or'; |
| 79 | + left: Expr; |
| 80 | + right: Expr; |
| 81 | +} |
| 82 | + |
| 83 | +export const Or = 'Or'; |
| 84 | + |
| 85 | +export function isOr(item: unknown): item is Or { |
| 86 | + return reflection.isInstance(item, Or); |
| 87 | +} |
| 88 | + |
| 89 | +export type LimbooleAstType = { |
| 90 | + And: And |
| 91 | + Expr: Expr |
| 92 | + Iff: Iff |
| 93 | + Implies: Implies |
| 94 | + Or: Or |
| 95 | +} |
| 96 | + |
| 97 | +export class LimbooleAstReflection extends AbstractAstReflection { |
| 98 | + |
| 99 | + getAllTypes(): string[] { |
| 100 | + return [And, Expr, Iff, Implies, Or]; |
| 101 | + } |
| 102 | + |
| 103 | + protected override computeIsSubtype(subtype: string, supertype: string): boolean { |
| 104 | + switch (subtype) { |
| 105 | + case And: |
| 106 | + case Iff: |
| 107 | + case Implies: |
| 108 | + case Or: { |
| 109 | + return this.isSubtype(Expr, supertype); |
| 110 | + } |
| 111 | + default: { |
| 112 | + return false; |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + |
| 117 | + getReferenceType(refInfo: ReferenceInfo): string { |
| 118 | + const referenceId = `${refInfo.container.$type}:${refInfo.property}`; |
| 119 | + switch (referenceId) { |
| 120 | + default: { |
| 121 | + throw new Error(`${referenceId} is not a valid reference id.`); |
| 122 | + } |
| 123 | + } |
| 124 | + } |
| 125 | + |
| 126 | + getTypeMetaData(type: string): TypeMetaData { |
| 127 | + switch (type) { |
| 128 | + case Expr: { |
| 129 | + return { |
| 130 | + name: Expr, |
| 131 | + properties: [ |
| 132 | + { name: 'var' } |
| 133 | + ] |
| 134 | + }; |
| 135 | + } |
| 136 | + case And: { |
| 137 | + return { |
| 138 | + name: And, |
| 139 | + properties: [ |
| 140 | + { name: 'left' }, |
| 141 | + { name: 'right' }, |
| 142 | + { name: 'var' } |
| 143 | + ] |
| 144 | + }; |
| 145 | + } |
| 146 | + case Iff: { |
| 147 | + return { |
| 148 | + name: Iff, |
| 149 | + properties: [ |
| 150 | + { name: 'left' }, |
| 151 | + { name: 'right' }, |
| 152 | + { name: 'var' } |
| 153 | + ] |
| 154 | + }; |
| 155 | + } |
| 156 | + case Implies: { |
| 157 | + return { |
| 158 | + name: Implies, |
| 159 | + properties: [ |
| 160 | + { name: 'left' }, |
| 161 | + { name: 'right' }, |
| 162 | + { name: 'var' } |
| 163 | + ] |
| 164 | + }; |
| 165 | + } |
| 166 | + case Or: { |
| 167 | + return { |
| 168 | + name: Or, |
| 169 | + properties: [ |
| 170 | + { name: 'left' }, |
| 171 | + { name: 'right' }, |
| 172 | + { name: 'var' } |
| 173 | + ] |
| 174 | + }; |
| 175 | + } |
| 176 | + default: { |
| 177 | + return { |
| 178 | + name: type, |
| 179 | + properties: [] |
| 180 | + }; |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | +} |
| 185 | + |
| 186 | +export const reflection = new LimbooleAstReflection(); |
0 commit comments