UNPKG

@cucumber/gherkin

Version:
161 lines (160 loc) 5.58 kB
import type { GherkinDocument, Location, StepKeywordType } from '@cucumber/messages'; import ITokenMatcher from './ITokenMatcher.js'; import GherkinLine from './GherkinLine.js'; import IToken, { Item } from './IToken.js'; import { IAstBuilder } from './IAstBuilder.js'; export declare class Token implements IToken<TokenType> { readonly line: GherkinLine; readonly location: Location; isEof: boolean; matchedText?: string; matchedType: TokenType; matchedItems: readonly Item[]; matchedKeyword: string; matchedIndent: number; matchedGherkinDialect: string; matchedKeywordType: StepKeywordType; constructor(line: GherkinLine, location: Location); getTokenValue(): string; } export declare enum TokenType { None = 0, EOF = 1, Empty = 2, Comment = 3, TagLine = 4, FeatureLine = 5, RuleLine = 6, BackgroundLine = 7, ScenarioLine = 8, ExamplesLine = 9, StepLine = 10, DocStringSeparator = 11, TableRow = 12, Language = 13, Other = 14 } export declare enum RuleType { None = 0, _EOF = 1,// #EOF _Empty = 2,// #Empty _Comment = 3,// #Comment _TagLine = 4,// #TagLine _FeatureLine = 5,// #FeatureLine _RuleLine = 6,// #RuleLine _BackgroundLine = 7,// #BackgroundLine _ScenarioLine = 8,// #ScenarioLine _ExamplesLine = 9,// #ExamplesLine _StepLine = 10,// #StepLine _DocStringSeparator = 11,// #DocStringSeparator _TableRow = 12,// #TableRow _Language = 13,// #Language _Other = 14,// #Other GherkinDocument = 15,// GherkinDocument! := Feature? Feature = 16,// Feature! := FeatureHeader Background? ScenarioDefinition* Rule* FeatureHeader = 17,// FeatureHeader! := #Language? Tags? #FeatureLine DescriptionHelper Rule = 18,// Rule! := RuleHeader Background? ScenarioDefinition* RuleHeader = 19,// RuleHeader! := Tags? #RuleLine DescriptionHelper Background = 20,// Background! := #BackgroundLine DescriptionHelper Step* ScenarioDefinition = 21,// ScenarioDefinition! [#Empty|#Comment|#TagLine->#ScenarioLine] := Tags? Scenario Scenario = 22,// Scenario! := #ScenarioLine DescriptionHelper Step* ExamplesDefinition* ExamplesDefinition = 23,// ExamplesDefinition! [#Empty|#Comment|#TagLine->#ExamplesLine] := Tags? Examples Examples = 24,// Examples! := #ExamplesLine DescriptionHelper ExamplesTable? ExamplesTable = 25,// ExamplesTable! := #TableRow #TableRow* Step = 26,// Step! := #StepLine StepArg? StepArg = 27,// StepArg := (DataTableAndMaybeDocString | DocStringAndMaybeDataTable) DataTableAndMaybeDocString = 28,// DataTableAndMaybeDocString := DataTable DocString? DocStringAndMaybeDataTable = 29,// DocStringAndMaybeDataTable := DocString DataTable? DataTable = 30,// DataTable! := #TableRow+ DocString = 31,// DocString! := #DocStringSeparator #Other* #DocStringSeparator Tags = 32,// Tags! := #TagLine+ DescriptionHelper = 33,// DescriptionHelper := #Empty* Description? Description = 34 } export default class Parser<AstNode> { private readonly builder; private readonly tokenMatcher; stopAtFirstError: boolean; private context; constructor(builder: IAstBuilder<AstNode, TokenType, RuleType>, tokenMatcher: ITokenMatcher<TokenType>); parse(gherkinSource: string): GherkinDocument; private addError; private startRule; private endRule; private build; private getResult; private handleAstError; private handleExternalError; private readToken; private matchToken; private matchTokenAt_0; private matchTokenAt_1; private matchTokenAt_2; private matchTokenAt_3; private matchTokenAt_4; private matchTokenAt_5; private matchTokenAt_6; private matchTokenAt_7; private matchTokenAt_8; private matchTokenAt_9; private matchTokenAt_10; private matchTokenAt_11; private matchTokenAt_12; private matchTokenAt_13; private matchTokenAt_14; private matchTokenAt_15; private matchTokenAt_16; private matchTokenAt_17; private matchTokenAt_18; private matchTokenAt_19; private matchTokenAt_20; private matchTokenAt_21; private matchTokenAt_22; private matchTokenAt_23; private matchTokenAt_24; private matchTokenAt_25; private matchTokenAt_26; private matchTokenAt_27; private matchTokenAt_28; private matchTokenAt_29; private matchTokenAt_30; private matchTokenAt_31; private matchTokenAt_32; private matchTokenAt_33; private matchTokenAt_34; private matchTokenAt_35; private matchTokenAt_36; private matchTokenAt_37; private matchTokenAt_38; private matchTokenAt_39; private matchTokenAt_40; private matchTokenAt_41; private matchTokenAt_43; private matchTokenAt_44; private matchTokenAt_45; private matchTokenAt_46; private matchTokenAt_47; private matchTokenAt_48; private matchTokenAt_49; private matchTokenAt_50; private matchTokenAt_51; private matchTokenAt_52; private matchTokenAt_53; private matchTokenAt_54; private match_EOF; private match_Empty; private match_Comment; private match_TagLine; private match_FeatureLine; private match_RuleLine; private match_BackgroundLine; private match_ScenarioLine; private match_ExamplesLine; private match_StepLine; private match_DocStringSeparator; private match_TableRow; private match_Language; private match_Other; private lookahead_0; private lookahead_1; }