// ------------------------------------------------------------------------------ // // This code was generated by Berp (http://https://github.com/gasparnagy/berp/). // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // // ------------------------------------------------------------------------------ #import typedef enum GHTokenType { GHTokenTypeNone, GHTokenTypeEOF, GHTokenTypeEmpty, GHTokenTypeComment, GHTokenTypeTagLine, GHTokenTypeFeatureLine, GHTokenTypeBackgroundLine, GHTokenTypeScenarioLine, GHTokenTypeScenarioOutlineLine, GHTokenTypeExamplesLine, GHTokenTypeStepLine, GHTokenTypeDocStringSeparator, GHTokenTypeTableRow, GHTokenTypeLanguage, GHTokenTypeOther, } GHTokenType; typedef enum GHRuleType { GHRuleTypeNone, GHRuleType_EOF, // #EOF GHRuleType_Empty, // #Empty GHRuleType_Comment, // #Comment GHRuleType_TagLine, // #TagLine GHRuleType_FeatureLine, // #FeatureLine GHRuleType_BackgroundLine, // #BackgroundLine GHRuleType_ScenarioLine, // #ScenarioLine GHRuleType_ScenarioOutlineLine, // #ScenarioOutlineLine GHRuleType_ExamplesLine, // #ExamplesLine GHRuleType_StepLine, // #StepLine GHRuleType_DocStringSeparator, // #DocStringSeparator GHRuleType_TableRow, // #TableRow GHRuleType_Language, // #Language GHRuleType_Other, // #Other GHRuleTypeFeature, // Feature! := Feature_Header Background? Scenario_Definition* GHRuleTypeFeature_Header, // Feature_Header! := #Language? Tags? #FeatureLine Feature_Description GHRuleTypeBackground, // Background! := #BackgroundLine Background_Description Scenario_Step* GHRuleTypeScenario_Definition, // Scenario_Definition! := Tags? (Scenario | ScenarioOutline) GHRuleTypeScenario, // Scenario! := #ScenarioLine Scenario_Description Scenario_Step* GHRuleTypeScenarioOutline, // ScenarioOutline! := #ScenarioOutlineLine ScenarioOutline_Description ScenarioOutline_Step* Examples_Definition* GHRuleTypeExamples_Definition, // Examples_Definition! [#Empty|#Comment|#TagLine->#ExamplesLine] := Tags? Examples GHRuleTypeExamples, // Examples! := #ExamplesLine Examples_Description Examples_Table? GHRuleTypeExamples_Table, // Examples_Table! := #TableRow #TableRow* GHRuleTypeScenario_Step, // Scenario_Step := Step GHRuleTypeScenarioOutline_Step, // ScenarioOutline_Step := Step GHRuleTypeStep, // Step! := #StepLine Step_Arg? GHRuleTypeStep_Arg, // Step_Arg := (DataTable | DocString) GHRuleTypeDataTable, // DataTable! := #TableRow+ GHRuleTypeDocString, // DocString! := #DocStringSeparator #Other* #DocStringSeparator GHRuleTypeTags, // Tags! := #TagLine+ GHRuleTypeFeature_Description, // Feature_Description := Description_Helper GHRuleTypeBackground_Description, // Background_Description := Description_Helper GHRuleTypeScenario_Description, // Scenario_Description := Description_Helper GHRuleTypeScenarioOutline_Description, // ScenarioOutline_Description := Description_Helper GHRuleTypeExamples_Description, // Examples_Description := Description_Helper GHRuleTypeDescription_Helper, // Description_Helper := #Empty* Description? #Comment* GHRuleTypeDescription, // Description! := #Other+ } GHRuleType; #import "GHToken.h" #import "GHParserException.h" @protocol GHAstBuilderProtocol - (void)buildWithToken:(GHToken *)theToken; - (void)startRuleWithType:(GHRuleType)theRuleType; - (void)endRuleWithType:(GHRuleType)theRuleType; - (id)result; - (void)reset; @end @protocol GHTokenScannerProtocol - (GHToken *)read; @end @protocol GHTokenMatcherProtocol - (BOOL)matchEOFWithToken:(GHToken *)theToken; - (BOOL)matchEmptyWithToken:(GHToken *)theToken; - (BOOL)matchCommentWithToken:(GHToken *)theToken; - (BOOL)matchTagLineWithToken:(GHToken *)theToken; - (BOOL)matchFeatureLineWithToken:(GHToken *)theToken; - (BOOL)matchBackgroundLineWithToken:(GHToken *)theToken; - (BOOL)matchScenarioLineWithToken:(GHToken *)theToken; - (BOOL)matchScenarioOutlineLineWithToken:(GHToken *)theToken; - (BOOL)matchExamplesLineWithToken:(GHToken *)theToken; - (BOOL)matchStepLineWithToken:(GHToken *)theToken; - (BOOL)matchDocStringSeparatorWithToken:(GHToken *)theToken; - (BOOL)matchTableRowWithToken:(GHToken *)theToken; - (BOOL)matchLanguageWithToken:(GHToken *)theToken; - (BOOL)matchOtherWithToken:(GHToken *)theToken; - (void)reset; @end #import "GHAstBuilder.h" #import "GHTokenMatcher.h" #import "GHParserException.h" @interface GHParserContext : NSObject @property (nonatomic, strong) id tokenScanner; @property (nonatomic, strong) id tokenMatcher; @property (nonatomic, strong) NSMutableArray * tokenQueue; @property (nonatomic, strong) NSMutableArray * errors; @end @interface GHParser : NSObject @property (nonatomic, assign) BOOL stopAtFirstError; - (id)initWithAstBuilder:(id)theAstBuilder; - (id)parseWithTokenScanner:(id)theTokenScanner; - (id)parseWithTokenScanner:(id)theTokenScanner tokenMatcher:(id)theTokenMatcher; @end