/******************************************************************************
 * This file was generated by langium-cli 0.2.0.
 * DO NOT EDIT MANUALLY!
 ******************************************************************************/ import { AstNode , AstReflection , Reference } from '../../syntax-tree' ; import { isAstNode } from '../../utils/ast-util' ; export interface AbstractElement extends AstNode { readonly $container : ParserRule | Alternatives | Group | UnorderedGroup | Assignment | CrossReference | TerminalRule | TerminalAlternatives | TerminalGroup | NegatedToken | UntilToken | CharacterRange ; cardinality : '?' | '*' | '+' ; } export const AbstractElement = 'AbstractElement' ; export function isAbstractElement ( item ) { return reflection . isInstance ( item , AbstractElement ) ; } export interface AbstractRule extends AstNode { readonly $container : Grammar ; fragment : boolean ; name : string ; type : string ; } export const AbstractRule = 'AbstractRule' ; export function isAbstractRule ( item ) { return reflection . isInstance ( item , AbstractRule ) ; } export interface Condition extends AstNode { readonly $container : Group | NamedArgument | Disjunction | Conjunction | Negation ; } export const Condition = 'Condition' ; export function isCondition ( item ) { return reflection . isInstance ( item , Condition ) ; } export interface Grammar extends AstNode { definesHiddenTokens : boolean ; hiddenTokens : Array < Reference < AbstractRule > > ; imports : Array < GrammarImport > ; name : string ; rules : Array < AbstractRule > ; usedGrammars : Array < Reference < Grammar > > ; } export const Grammar = 'Grammar' ; export function isGrammar ( item ) { return reflection . isInstance ( item , Grammar ) ; } export interface GrammarImport extends AstNode { readonly $container : Grammar ; path : string ; } export const GrammarImport = 'GrammarImport' ; export function isGrammarImport ( item ) { return reflection . isInstance ( item , GrammarImport ) ; } export interface NamedArgument extends AstNode { readonly $container : RuleCall ; calledByName : boolean ; parameter ? : Reference < Parameter > ; value : Condition ; } export const NamedArgument = 'NamedArgument' ; export function isNamedArgument ( item ) { return reflection . isInstance ( item , NamedArgument ) ; } export interface Parameter extends AstNode { readonly $container : ParserRule ; name : string ; } export const Parameter = 'Parameter' ; export function isParameter ( item ) { return reflection . isInstance ( item , Parameter ) ; } export interface Action extends AbstractElement { feature : string ; operator : '=' | '+=' ; type : string ; } export const Action = 'Action' ; export function isAction ( item ) { return reflection . isInstance ( item , Action ) ; } export interface Alternatives extends AbstractElement { elements : Array < AbstractElement > ; } export const Alternatives = 'Alternatives' ; export function isAlternatives ( item ) { return reflection . isInstance ( item , Alternatives ) ; } export interface Assignment extends AbstractElement { feature : string ; firstSetPredicated : boolean ; operator : '+=' | '=' | '?=' ; predicated : boolean ; terminal : AbstractElement ; } export const Assignment = 'Assignment' ; export function isAssignment ( item ) { return reflection . isInstance ( item , Assignment ) ; } export interface CharacterRange extends AbstractElement { left : Keyword ; right : Keyword ; } export const CharacterRange = 'CharacterRange' ; export function isCharacterRange ( item ) { return reflection . isInstance ( item , CharacterRange ) ; } export interface CrossReference extends AbstractElement { deprecatedSyntax : boolean ; terminal : AbstractElement ; type : Reference < ParserRule > ; } export const CrossReference = 'CrossReference' ; export function isCrossReference ( item ) { return reflection . isInstance ( item , CrossReference ) ; } export interface Group extends AbstractElement { elements : Array < AbstractElement > ; firstSetPredicated : boolean ; guardCondition : Condition ; predicated : boolean ; } export const Group = 'Group' ; export function isGroup ( item ) { return reflection . isInstance ( item , Group ) ; } export interface Keyword extends AbstractElement { firstSetPredicated : boolean ; predicated : boolean ; value : string ; } export const Keyword = 'Keyword' ; export function isKeyword ( item ) { return reflection . isInstance ( item , Keyword ) ; } export interface NegatedToken extends AbstractElement { terminal : AbstractElement ; } export const NegatedToken = 'NegatedToken' ; export function isNegatedToken ( item ) { return reflection . isInstance ( item , NegatedToken ) ; } export interface RegexToken extends AbstractElement { regex : string ; } export const RegexToken = 'RegexToken' ; export function isRegexToken ( item ) { return reflection . isInstance ( item , RegexToken ) ; } export interface RuleCall extends AbstractElement { arguments : Array < NamedArgument > ; firstSetPredicated : boolean ; predicated : boolean ; rule : Reference < AbstractRule > ; } export const RuleCall = 'RuleCall' ; export function isRuleCall ( item ) { return reflection . isInstance ( item , RuleCall ) ; } export interface TerminalAlternatives extends AbstractElement { elements : Array < AbstractElement > ; } export const TerminalAlternatives = 'TerminalAlternatives' ; export function isTerminalAlternatives ( item ) { return reflection . isInstance ( item , TerminalAlternatives ) ; } export interface TerminalGroup extends AbstractElement { elements : Array < AbstractElement > ; } export const TerminalGroup = 'TerminalGroup' ; export function isTerminalGroup ( item ) { return reflection . isInstance ( item , TerminalGroup ) ; } export interface TerminalRuleCall extends AbstractElement { rule : Reference < TerminalRule > ; } export const TerminalRuleCall = 'TerminalRuleCall' ; export function isTerminalRuleCall ( item ) { return reflection . isInstance ( item , TerminalRuleCall ) ; } export interface UnorderedGroup extends AbstractElement { elements : Array < AbstractElement > ; } export const UnorderedGroup = 'UnorderedGroup' ; export function isUnorderedGroup ( item ) { return reflection . isInstance ( item , UnorderedGroup ) ; } export interface UntilToken extends AbstractElement { terminal : AbstractElement ; } export const UntilToken = 'UntilToken' ; export function isUntilToken ( item ) { return reflection . isInstance ( item , UntilToken ) ; } export interface Wildcard extends AbstractElement { } export const Wildcard = 'Wildcard' ; export function isWildcard ( item ) { return reflection . isInstance ( item , Wildcard ) ; } export interface ParserRule extends AbstractRule { alternatives : AbstractElement ; definesHiddenTokens : boolean ; entry : boolean ; hiddenTokens : Array < Reference < AbstractRule > > ; parameters : Array < Parameter > ; wildcard : boolean ; } export const ParserRule = 'ParserRule' ; export function isParserRule ( item ) { return reflection . isInstance ( item , ParserRule ) ; } export interface TerminalRule extends AbstractRule { hidden : boolean ; terminal : AbstractElement ; } export const TerminalRule = 'TerminalRule' ; export function isTerminalRule ( item ) { return reflection . isInstance ( item , TerminalRule ) ; } export interface Conjunction extends Condition { left : Condition ; right : Condition ; } export const Conjunction = 'Conjunction' ; export function isConjunction ( item ) { return reflection . isInstance ( item , Conjunction ) ; } export interface Disjunction extends Condition { left : Condition ; right : Condition ; } export const Disjunction = 'Disjunction' ; export function isDisjunction ( item ) { return reflection . isInstance ( item , Disjunction ) ; } export interface LiteralCondition extends Condition { true : boolean ; } export const LiteralCondition = 'LiteralCondition' ; export function isLiteralCondition ( item ) { return reflection . isInstance ( item , LiteralCondition ) ; } export interface Negation extends Condition { value : Condition ; } export const Negation = 'Negation' ; export function isNegation ( item ) { return reflection . isInstance ( item , Negation ) ; } export interface ParameterReference extends Condition { parameter : Reference < Parameter > ; } export const ParameterReference = 'ParameterReference' ; export function isParameterReference ( item ) { return reflection . isInstance ( item , ParameterReference ) ; } export type LangiumGrammarAstType = 'AbstractElement' | 'AbstractRule' | 'Condition' | 'Grammar' | 'GrammarImport' | 'NamedArgument' | 'Parameter' | 'Action' | 'Alternatives' | 'Assignment' | 'CharacterRange' | 'CrossReference' | 'Group' | 'Keyword' | 'NegatedToken' | 'RegexToken' | 'RuleCall' | 'TerminalAlternatives' | 'TerminalGroup' | 'TerminalRuleCall' | 'UnorderedGroup' | 'UntilToken' | 'Wildcard' | 'ParserRule' | 'TerminalRule' | 'Conjunction' | 'Disjunction' | 'LiteralCondition' | 'Negation' | 'ParameterReference' ; export type LangiumGrammarAstReference = 'Grammar:hiddenTokens' | 'Grammar:usedGrammars' | 'NamedArgument:parameter' | 'CrossReference:type' | 'RuleCall:rule' | 'TerminalRuleCall:rule' | 'ParserRule:hiddenTokens' | 'ParameterReference:parameter' ; export class LangiumGrammarAstReflection implements AstReflection { getAllTypes ( ) { return [ 'AbstractElement' , 'AbstractRule' , 'Condition' , 'Grammar' , 'GrammarImport' , 'NamedArgument' , 'Parameter' , 'Action' , 'Alternatives' , 'Assignment' , 'CharacterRange' , 'CrossReference' , 'Group' , 'Keyword' , 'NegatedToken' , 'RegexToken' , 'RuleCall' , 'TerminalAlternatives' , 'TerminalGroup' , 'TerminalRuleCall' , 'UnorderedGroup' , 'UntilToken' , 'Wildcard' , 'ParserRule' , 'TerminalRule' , 'Conjunction' , 'Disjunction' , 'LiteralCondition' , 'Negation' , 'ParameterReference' ] ; } isInstance ( node , type ) { return isAstNode ( node ) && this . isSubtype ( node . $type , type ) ; } isSubtype ( subtype , supertype ) { if ( subtype === supertype ) { return true ; } switch ( subtype ) { case Action : case Alternatives : case Assignment : case CharacterRange : case CrossReference : case Group : case Keyword : case NegatedToken : case RegexToken : case RuleCall : case TerminalAlternatives : case TerminalGroup : case TerminalRuleCall : case UnorderedGroup : case UntilToken : case Wildcard : { return this . isSubtype ( AbstractElement , supertype ) ; } case ParserRule : case TerminalRule : { return this . isSubtype ( AbstractRule , supertype ) ; } case Conjunction : case Disjunction : case LiteralCondition : case Negation : case ParameterReference : { return this . isSubtype ( Condition , supertype ) ; } default : { return false ; } } } getReferenceType ( referenceId ) { switch ( referenceId ) { case 'Grammar:hiddenTokens' : { return AbstractRule ; } case 'Grammar:usedGrammars' : { return Grammar ; } case 'NamedArgument:parameter' : { return Parameter ; } case 'CrossReference:type' : { return ParserRule ; } case 'RuleCall:rule' : { return AbstractRule ; } case 'TerminalRuleCall:rule' : { return TerminalRule ; } case 'ParserRule:hiddenTokens' : { return AbstractRule ; } case 'ParameterReference:parameter' : { return Parameter ; } default : { throw new Error ( `${ referenceId } is not a valid reference id.` ) ; } } } } export const reflection = new LangiumGrammarAstReflection ( ) ;