Best JavaScript code snippet using cucumber-gherkin
gherkin.js
Source:gherkin.js
...3885 return matchTokenAt_7(token, context);3886 case 8:3887 return matchTokenAt_8(token, context);3888 case 9:3889 return matchTokenAt_9(token, context);3890 case 10:3891 return matchTokenAt_10(token, context);3892 case 11:3893 return matchTokenAt_11(token, context);3894 case 12:3895 return matchTokenAt_12(token, context);3896 case 13:3897 return matchTokenAt_13(token, context);3898 case 14:3899 return matchTokenAt_14(token, context);3900 case 15:3901 return matchTokenAt_15(token, context);3902 case 16:3903 return matchTokenAt_16(token, context);3904 case 17:3905 return matchTokenAt_17(token, context);3906 case 18:3907 return matchTokenAt_18(token, context);3908 case 19:3909 return matchTokenAt_19(token, context);3910 case 20:3911 return matchTokenAt_20(token, context);3912 case 21:3913 return matchTokenAt_21(token, context);3914 case 22:3915 return matchTokenAt_22(token, context);3916 case 23:3917 return matchTokenAt_23(token, context);3918 case 24:3919 return matchTokenAt_24(token, context);3920 case 25:3921 return matchTokenAt_25(token, context);3922 case 26:3923 return matchTokenAt_26(token, context);3924 case 28:3925 return matchTokenAt_28(token, context);3926 case 29:3927 return matchTokenAt_29(token, context);3928 case 30:3929 return matchTokenAt_30(token, context);3930 case 31:3931 return matchTokenAt_31(token, context);3932 case 32:3933 return matchTokenAt_32(token, context);3934 case 33:3935 return matchTokenAt_33(token, context);3936 default:3937 throw new Error("Unknown state: " + state);3938 }3939 }3940 // Start3941 function matchTokenAt_0(token, context) {3942 if(match_EOF(context, token)) {3943 build(context, token);3944 return 27;3945 }3946 if(match_Language(context, token)) {3947 startRule(context, 'Feature');3948 startRule(context, 'Feature_Header');3949 build(context, token);3950 return 1;3951 }3952 if(match_TagLine(context, token)) {3953 startRule(context, 'Feature');3954 startRule(context, 'Feature_Header');3955 startRule(context, 'Tags');3956 build(context, token);3957 return 2;3958 }3959 if(match_FeatureLine(context, token)) {3960 startRule(context, 'Feature');3961 startRule(context, 'Feature_Header');3962 build(context, token);3963 return 3;3964 }3965 if(match_Comment(context, token)) {3966 build(context, token);3967 return 0;3968 }3969 if(match_Empty(context, token)) {3970 build(context, token);3971 return 0;3972 }3973 3974 var stateComment = "State: 0 - Start";3975 token.detach();3976 var expectedTokens = ["#EOF", "#Language", "#TagLine", "#FeatureLine", "#Comment", "#Empty"];3977 var error = token.isEof ?3978 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :3979 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);3980 if (self.stopAtFirstError) throw error;3981 addError(context, error);3982 return 0;3983 }3984 // GherkinDocument:0>Feature:0>Feature_Header:0>#Language:03985 function matchTokenAt_1(token, context) {3986 if(match_TagLine(context, token)) {3987 startRule(context, 'Tags');3988 build(context, token);3989 return 2;3990 }3991 if(match_FeatureLine(context, token)) {3992 build(context, token);3993 return 3;3994 }3995 if(match_Comment(context, token)) {3996 build(context, token);3997 return 1;3998 }3999 if(match_Empty(context, token)) {4000 build(context, token);4001 return 1;4002 }4003 4004 var stateComment = "State: 1 - GherkinDocument:0>Feature:0>Feature_Header:0>#Language:0";4005 token.detach();4006 var expectedTokens = ["#TagLine", "#FeatureLine", "#Comment", "#Empty"];4007 var error = token.isEof ?4008 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4009 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4010 if (self.stopAtFirstError) throw error;4011 addError(context, error);4012 return 1;4013 }4014 // GherkinDocument:0>Feature:0>Feature_Header:1>Tags:0>#TagLine:04015 function matchTokenAt_2(token, context) {4016 if(match_TagLine(context, token)) {4017 build(context, token);4018 return 2;4019 }4020 if(match_FeatureLine(context, token)) {4021 endRule(context, 'Tags');4022 build(context, token);4023 return 3;4024 }4025 if(match_Comment(context, token)) {4026 build(context, token);4027 return 2;4028 }4029 if(match_Empty(context, token)) {4030 build(context, token);4031 return 2;4032 }4033 4034 var stateComment = "State: 2 - GherkinDocument:0>Feature:0>Feature_Header:1>Tags:0>#TagLine:0";4035 token.detach();4036 var expectedTokens = ["#TagLine", "#FeatureLine", "#Comment", "#Empty"];4037 var error = token.isEof ?4038 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4039 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4040 if (self.stopAtFirstError) throw error;4041 addError(context, error);4042 return 2;4043 }4044 // GherkinDocument:0>Feature:0>Feature_Header:2>#FeatureLine:04045 function matchTokenAt_3(token, context) {4046 if(match_EOF(context, token)) {4047 endRule(context, 'Feature_Header');4048 endRule(context, 'Feature');4049 build(context, token);4050 return 27;4051 }4052 if(match_Empty(context, token)) {4053 build(context, token);4054 return 3;4055 }4056 if(match_Comment(context, token)) {4057 build(context, token);4058 return 5;4059 }4060 if(match_BackgroundLine(context, token)) {4061 endRule(context, 'Feature_Header');4062 startRule(context, 'Background');4063 build(context, token);4064 return 6;4065 }4066 if(match_TagLine(context, token)) {4067 endRule(context, 'Feature_Header');4068 startRule(context, 'Scenario_Definition');4069 startRule(context, 'Tags');4070 build(context, token);4071 return 11;4072 }4073 if(match_ScenarioLine(context, token)) {4074 endRule(context, 'Feature_Header');4075 startRule(context, 'Scenario_Definition');4076 startRule(context, 'Scenario');4077 build(context, token);4078 return 12;4079 }4080 if(match_ScenarioOutlineLine(context, token)) {4081 endRule(context, 'Feature_Header');4082 startRule(context, 'Scenario_Definition');4083 startRule(context, 'ScenarioOutline');4084 build(context, token);4085 return 17;4086 }4087 if(match_Other(context, token)) {4088 startRule(context, 'Description');4089 build(context, token);4090 return 4;4091 }4092 4093 var stateComment = "State: 3 - GherkinDocument:0>Feature:0>Feature_Header:2>#FeatureLine:0";4094 token.detach();4095 var expectedTokens = ["#EOF", "#Empty", "#Comment", "#BackgroundLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Other"];4096 var error = token.isEof ?4097 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4098 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4099 if (self.stopAtFirstError) throw error;4100 addError(context, error);4101 return 3;4102 }4103 // GherkinDocument:0>Feature:0>Feature_Header:3>Description_Helper:1>Description:0>#Other:04104 function matchTokenAt_4(token, context) {4105 if(match_EOF(context, token)) {4106 endRule(context, 'Description');4107 endRule(context, 'Feature_Header');4108 endRule(context, 'Feature');4109 build(context, token);4110 return 27;4111 }4112 if(match_Comment(context, token)) {4113 endRule(context, 'Description');4114 build(context, token);4115 return 5;4116 }4117 if(match_BackgroundLine(context, token)) {4118 endRule(context, 'Description');4119 endRule(context, 'Feature_Header');4120 startRule(context, 'Background');4121 build(context, token);4122 return 6;4123 }4124 if(match_TagLine(context, token)) {4125 endRule(context, 'Description');4126 endRule(context, 'Feature_Header');4127 startRule(context, 'Scenario_Definition');4128 startRule(context, 'Tags');4129 build(context, token);4130 return 11;4131 }4132 if(match_ScenarioLine(context, token)) {4133 endRule(context, 'Description');4134 endRule(context, 'Feature_Header');4135 startRule(context, 'Scenario_Definition');4136 startRule(context, 'Scenario');4137 build(context, token);4138 return 12;4139 }4140 if(match_ScenarioOutlineLine(context, token)) {4141 endRule(context, 'Description');4142 endRule(context, 'Feature_Header');4143 startRule(context, 'Scenario_Definition');4144 startRule(context, 'ScenarioOutline');4145 build(context, token);4146 return 17;4147 }4148 if(match_Other(context, token)) {4149 build(context, token);4150 return 4;4151 }4152 4153 var stateComment = "State: 4 - GherkinDocument:0>Feature:0>Feature_Header:3>Description_Helper:1>Description:0>#Other:0";4154 token.detach();4155 var expectedTokens = ["#EOF", "#Comment", "#BackgroundLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Other"];4156 var error = token.isEof ?4157 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4158 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4159 if (self.stopAtFirstError) throw error;4160 addError(context, error);4161 return 4;4162 }4163 // GherkinDocument:0>Feature:0>Feature_Header:3>Description_Helper:2>#Comment:04164 function matchTokenAt_5(token, context) {4165 if(match_EOF(context, token)) {4166 endRule(context, 'Feature_Header');4167 endRule(context, 'Feature');4168 build(context, token);4169 return 27;4170 }4171 if(match_Comment(context, token)) {4172 build(context, token);4173 return 5;4174 }4175 if(match_BackgroundLine(context, token)) {4176 endRule(context, 'Feature_Header');4177 startRule(context, 'Background');4178 build(context, token);4179 return 6;4180 }4181 if(match_TagLine(context, token)) {4182 endRule(context, 'Feature_Header');4183 startRule(context, 'Scenario_Definition');4184 startRule(context, 'Tags');4185 build(context, token);4186 return 11;4187 }4188 if(match_ScenarioLine(context, token)) {4189 endRule(context, 'Feature_Header');4190 startRule(context, 'Scenario_Definition');4191 startRule(context, 'Scenario');4192 build(context, token);4193 return 12;4194 }4195 if(match_ScenarioOutlineLine(context, token)) {4196 endRule(context, 'Feature_Header');4197 startRule(context, 'Scenario_Definition');4198 startRule(context, 'ScenarioOutline');4199 build(context, token);4200 return 17;4201 }4202 if(match_Empty(context, token)) {4203 build(context, token);4204 return 5;4205 }4206 4207 var stateComment = "State: 5 - GherkinDocument:0>Feature:0>Feature_Header:3>Description_Helper:2>#Comment:0";4208 token.detach();4209 var expectedTokens = ["#EOF", "#Comment", "#BackgroundLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Empty"];4210 var error = token.isEof ?4211 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4212 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4213 if (self.stopAtFirstError) throw error;4214 addError(context, error);4215 return 5;4216 }4217 // GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:04218 function matchTokenAt_6(token, context) {4219 if(match_EOF(context, token)) {4220 endRule(context, 'Background');4221 endRule(context, 'Feature');4222 build(context, token);4223 return 27;4224 }4225 if(match_Empty(context, token)) {4226 build(context, token);4227 return 6;4228 }4229 if(match_Comment(context, token)) {4230 build(context, token);4231 return 8;4232 }4233 if(match_StepLine(context, token)) {4234 startRule(context, 'Step');4235 build(context, token);4236 return 9;4237 }4238 if(match_TagLine(context, token)) {4239 endRule(context, 'Background');4240 startRule(context, 'Scenario_Definition');4241 startRule(context, 'Tags');4242 build(context, token);4243 return 11;4244 }4245 if(match_ScenarioLine(context, token)) {4246 endRule(context, 'Background');4247 startRule(context, 'Scenario_Definition');4248 startRule(context, 'Scenario');4249 build(context, token);4250 return 12;4251 }4252 if(match_ScenarioOutlineLine(context, token)) {4253 endRule(context, 'Background');4254 startRule(context, 'Scenario_Definition');4255 startRule(context, 'ScenarioOutline');4256 build(context, token);4257 return 17;4258 }4259 if(match_Other(context, token)) {4260 startRule(context, 'Description');4261 build(context, token);4262 return 7;4263 }4264 4265 var stateComment = "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0";4266 token.detach();4267 var expectedTokens = ["#EOF", "#Empty", "#Comment", "#StepLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Other"];4268 var error = token.isEof ?4269 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4270 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4271 if (self.stopAtFirstError) throw error;4272 addError(context, error);4273 return 6;4274 }4275 // GherkinDocument:0>Feature:1>Background:1>Description_Helper:1>Description:0>#Other:04276 function matchTokenAt_7(token, context) {4277 if(match_EOF(context, token)) {4278 endRule(context, 'Description');4279 endRule(context, 'Background');4280 endRule(context, 'Feature');4281 build(context, token);4282 return 27;4283 }4284 if(match_Comment(context, token)) {4285 endRule(context, 'Description');4286 build(context, token);4287 return 8;4288 }4289 if(match_StepLine(context, token)) {4290 endRule(context, 'Description');4291 startRule(context, 'Step');4292 build(context, token);4293 return 9;4294 }4295 if(match_TagLine(context, token)) {4296 endRule(context, 'Description');4297 endRule(context, 'Background');4298 startRule(context, 'Scenario_Definition');4299 startRule(context, 'Tags');4300 build(context, token);4301 return 11;4302 }4303 if(match_ScenarioLine(context, token)) {4304 endRule(context, 'Description');4305 endRule(context, 'Background');4306 startRule(context, 'Scenario_Definition');4307 startRule(context, 'Scenario');4308 build(context, token);4309 return 12;4310 }4311 if(match_ScenarioOutlineLine(context, token)) {4312 endRule(context, 'Description');4313 endRule(context, 'Background');4314 startRule(context, 'Scenario_Definition');4315 startRule(context, 'ScenarioOutline');4316 build(context, token);4317 return 17;4318 }4319 if(match_Other(context, token)) {4320 build(context, token);4321 return 7;4322 }4323 4324 var stateComment = "State: 7 - GherkinDocument:0>Feature:1>Background:1>Description_Helper:1>Description:0>#Other:0";4325 token.detach();4326 var expectedTokens = ["#EOF", "#Comment", "#StepLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Other"];4327 var error = token.isEof ?4328 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4329 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4330 if (self.stopAtFirstError) throw error;4331 addError(context, error);4332 return 7;4333 }4334 // GherkinDocument:0>Feature:1>Background:1>Description_Helper:2>#Comment:04335 function matchTokenAt_8(token, context) {4336 if(match_EOF(context, token)) {4337 endRule(context, 'Background');4338 endRule(context, 'Feature');4339 build(context, token);4340 return 27;4341 }4342 if(match_Comment(context, token)) {4343 build(context, token);4344 return 8;4345 }4346 if(match_StepLine(context, token)) {4347 startRule(context, 'Step');4348 build(context, token);4349 return 9;4350 }4351 if(match_TagLine(context, token)) {4352 endRule(context, 'Background');4353 startRule(context, 'Scenario_Definition');4354 startRule(context, 'Tags');4355 build(context, token);4356 return 11;4357 }4358 if(match_ScenarioLine(context, token)) {4359 endRule(context, 'Background');4360 startRule(context, 'Scenario_Definition');4361 startRule(context, 'Scenario');4362 build(context, token);4363 return 12;4364 }4365 if(match_ScenarioOutlineLine(context, token)) {4366 endRule(context, 'Background');4367 startRule(context, 'Scenario_Definition');4368 startRule(context, 'ScenarioOutline');4369 build(context, token);4370 return 17;4371 }4372 if(match_Empty(context, token)) {4373 build(context, token);4374 return 8;4375 }4376 4377 var stateComment = "State: 8 - GherkinDocument:0>Feature:1>Background:1>Description_Helper:2>#Comment:0";4378 token.detach();4379 var expectedTokens = ["#EOF", "#Comment", "#StepLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Empty"];4380 var error = token.isEof ?4381 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4382 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4383 if (self.stopAtFirstError) throw error;4384 addError(context, error);4385 return 8;4386 }4387 // GherkinDocument:0>Feature:1>Background:2>Step:0>#StepLine:04388 function matchTokenAt_9(token, context) {4389 if(match_EOF(context, token)) {4390 endRule(context, 'Step');4391 endRule(context, 'Background');4392 endRule(context, 'Feature');4393 build(context, token);4394 return 27;4395 }4396 if(match_TableRow(context, token)) {4397 startRule(context, 'DataTable');4398 build(context, token);4399 return 10;4400 }4401 if(match_DocStringSeparator(context, token)) {4402 startRule(context, 'DocString');...
parser.js
Source:parser.js
...131 return matchTokenAt_6(token, context);132 case 8:133 return matchTokenAt_8(token, context);134 case 9:135 return matchTokenAt_9(token, context);136 default:137 throw new Error("Unknown state: " + state);138 }139 }140 // Start141 function matchTokenAt_0(token, context) {142 if(match_EOF(context, token)) {143 build(context, token);144 return 7;145 }146 if(match_TagLine(context, token)) {147 startRule(context, 'Scenario_Definition');148 startRule(context, 'Tags');149 build(context, token);150 return 1;151 }152 if(match_ScenarioLine(context, token)) {153 startRule(context, 'Scenario_Definition');154 startRule(context, 'Scenario');155 build(context, token);156 return 2;157 }158 if(match_Comment(context, token)) {159 build(context, token);160 return 0;161 }162 if(match_Empty(context, token)) {163 build(context, token);164 return 0;165 }166 167 var stateComment = "State: 0 - Start";168 token.detach();169 var expectedTokens = ["#EOF", "#TagLine", "#ScenarioLine", "#Comment", "#Empty"];170 var error = token.isEof ?171 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :172 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);173 if (self.stopAtFirstError) throw error;174 addError(context, error);175 return 0;176 }177 // GherkinDocument:0>Scenario_Definition:0>Tags:0>#TagLine:0178 function matchTokenAt_1(token, context) {179 if(match_TagLine(context, token)) {180 build(context, token);181 return 1;182 }183 if(match_ScenarioLine(context, token)) {184 endRule(context, 'Tags');185 startRule(context, 'Scenario');186 build(context, token);187 return 2;188 }189 if(match_Comment(context, token)) {190 build(context, token);191 return 1;192 }193 if(match_Empty(context, token)) {194 build(context, token);195 return 1;196 }197 198 var stateComment = "State: 1 - GherkinDocument:0>Scenario_Definition:0>Tags:0>#TagLine:0";199 token.detach();200 var expectedTokens = ["#TagLine", "#ScenarioLine", "#Comment", "#Empty"];201 var error = token.isEof ?202 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :203 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);204 if (self.stopAtFirstError) throw error;205 addError(context, error);206 return 1;207 }208 // GherkinDocument:0>Scenario_Definition:1>Scenario:0>#ScenarioLine:0209 function matchTokenAt_2(token, context) {210 if(match_EOF(context, token)) {211 endRule(context, 'Scenario');212 endRule(context, 'Scenario_Definition');213 build(context, token);214 return 7;215 }216 if(match_Empty(context, token)) {217 build(context, token);218 return 2;219 }220 if(match_Comment(context, token)) {221 build(context, token);222 return 4;223 }224 if(match_StepLine(context, token)) {225 startRule(context, 'Step');226 build(context, token);227 return 5;228 }229 if(match_TagLine(context, token)) {230 endRule(context, 'Scenario');231 endRule(context, 'Scenario_Definition');232 startRule(context, 'Scenario_Definition');233 startRule(context, 'Tags');234 build(context, token);235 return 1;236 }237 if(match_ScenarioLine(context, token)) {238 endRule(context, 'Scenario');239 endRule(context, 'Scenario_Definition');240 startRule(context, 'Scenario_Definition');241 startRule(context, 'Scenario');242 build(context, token);243 return 2;244 }245 if(match_Other(context, token)) {246 startRule(context, 'Description');247 build(context, token);248 return 3;249 }250 251 var stateComment = "State: 2 - GherkinDocument:0>Scenario_Definition:1>Scenario:0>#ScenarioLine:0";252 token.detach();253 var expectedTokens = ["#EOF", "#Empty", "#Comment", "#StepLine", "#TagLine", "#ScenarioLine", "#Other"];254 var error = token.isEof ?255 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :256 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);257 if (self.stopAtFirstError) throw error;258 addError(context, error);259 return 2;260 }261 // GherkinDocument:0>Scenario_Definition:1>Scenario:1>Scenario_Description:0>Description_Helper:1>Description:0>#Other:0262 function matchTokenAt_3(token, context) {263 if(match_EOF(context, token)) {264 endRule(context, 'Description');265 endRule(context, 'Scenario');266 endRule(context, 'Scenario_Definition');267 build(context, token);268 return 7;269 }270 if(match_Comment(context, token)) {271 endRule(context, 'Description');272 build(context, token);273 return 4;274 }275 if(match_StepLine(context, token)) {276 endRule(context, 'Description');277 startRule(context, 'Step');278 build(context, token);279 return 5;280 }281 if(match_TagLine(context, token)) {282 endRule(context, 'Description');283 endRule(context, 'Scenario');284 endRule(context, 'Scenario_Definition');285 startRule(context, 'Scenario_Definition');286 startRule(context, 'Tags');287 build(context, token);288 return 1;289 }290 if(match_ScenarioLine(context, token)) {291 endRule(context, 'Description');292 endRule(context, 'Scenario');293 endRule(context, 'Scenario_Definition');294 startRule(context, 'Scenario_Definition');295 startRule(context, 'Scenario');296 build(context, token);297 return 2;298 }299 if(match_Other(context, token)) {300 build(context, token);301 return 3;302 }303 304 var stateComment = "State: 3 - GherkinDocument:0>Scenario_Definition:1>Scenario:1>Scenario_Description:0>Description_Helper:1>Description:0>#Other:0";305 token.detach();306 var expectedTokens = ["#EOF", "#Comment", "#StepLine", "#TagLine", "#ScenarioLine", "#Other"];307 var error = token.isEof ?308 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :309 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);310 if (self.stopAtFirstError) throw error;311 addError(context, error);312 return 3;313 }314 // GherkinDocument:0>Scenario_Definition:1>Scenario:1>Scenario_Description:0>Description_Helper:2>#Comment:0315 function matchTokenAt_4(token, context) {316 if(match_EOF(context, token)) {317 endRule(context, 'Scenario');318 endRule(context, 'Scenario_Definition');319 build(context, token);320 return 7;321 }322 if(match_Comment(context, token)) {323 build(context, token);324 return 4;325 }326 if(match_StepLine(context, token)) {327 startRule(context, 'Step');328 build(context, token);329 return 5;330 }331 if(match_TagLine(context, token)) {332 endRule(context, 'Scenario');333 endRule(context, 'Scenario_Definition');334 startRule(context, 'Scenario_Definition');335 startRule(context, 'Tags');336 build(context, token);337 return 1;338 }339 if(match_ScenarioLine(context, token)) {340 endRule(context, 'Scenario');341 endRule(context, 'Scenario_Definition');342 startRule(context, 'Scenario_Definition');343 startRule(context, 'Scenario');344 build(context, token);345 return 2;346 }347 if(match_Empty(context, token)) {348 build(context, token);349 return 4;350 }351 352 var stateComment = "State: 4 - GherkinDocument:0>Scenario_Definition:1>Scenario:1>Scenario_Description:0>Description_Helper:2>#Comment:0";353 token.detach();354 var expectedTokens = ["#EOF", "#Comment", "#StepLine", "#TagLine", "#ScenarioLine", "#Empty"];355 var error = token.isEof ?356 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :357 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);358 if (self.stopAtFirstError) throw error;359 addError(context, error);360 return 4;361 }362 // GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:0>#StepLine:0363 function matchTokenAt_5(token, context) {364 if(match_EOF(context, token)) {365 endRule(context, 'Step');366 endRule(context, 'Scenario');367 endRule(context, 'Scenario_Definition');368 build(context, token);369 return 7;370 }371 if(match_TableRow(context, token)) {372 startRule(context, 'DataTable');373 build(context, token);374 return 6;375 }376 if(match_DocStringSeparator(context, token)) {377 startRule(context, 'DocString');378 build(context, token);379 return 8;380 }381 if(match_StepLine(context, token)) {382 endRule(context, 'Step');383 startRule(context, 'Step');384 build(context, token);385 return 5;386 }387 if(match_TagLine(context, token)) {388 endRule(context, 'Step');389 endRule(context, 'Scenario');390 endRule(context, 'Scenario_Definition');391 startRule(context, 'Scenario_Definition');392 startRule(context, 'Tags');393 build(context, token);394 return 1;395 }396 if(match_ScenarioLine(context, token)) {397 endRule(context, 'Step');398 endRule(context, 'Scenario');399 endRule(context, 'Scenario_Definition');400 startRule(context, 'Scenario_Definition');401 startRule(context, 'Scenario');402 build(context, token);403 return 2;404 }405 if(match_Comment(context, token)) {406 build(context, token);407 return 5;408 }409 if(match_Empty(context, token)) {410 build(context, token);411 return 5;412 }413 414 var stateComment = "State: 5 - GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:0>#StepLine:0";415 token.detach();416 var expectedTokens = ["#EOF", "#TableRow", "#DocStringSeparator", "#StepLine", "#TagLine", "#ScenarioLine", "#Comment", "#Empty"];417 var error = token.isEof ?418 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :419 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);420 if (self.stopAtFirstError) throw error;421 addError(context, error);422 return 5;423 }424 // GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:1>Step_Arg:0>__alt0:0>DataTable:0>#TableRow:0425 function matchTokenAt_6(token, context) {426 if(match_EOF(context, token)) {427 endRule(context, 'DataTable');428 endRule(context, 'Step');429 endRule(context, 'Scenario');430 endRule(context, 'Scenario_Definition');431 build(context, token);432 return 7;433 }434 if(match_TableRow(context, token)) {435 build(context, token);436 return 6;437 }438 if(match_StepLine(context, token)) {439 endRule(context, 'DataTable');440 endRule(context, 'Step');441 startRule(context, 'Step');442 build(context, token);443 return 5;444 }445 if(match_TagLine(context, token)) {446 endRule(context, 'DataTable');447 endRule(context, 'Step');448 endRule(context, 'Scenario');449 endRule(context, 'Scenario_Definition');450 startRule(context, 'Scenario_Definition');451 startRule(context, 'Tags');452 build(context, token);453 return 1;454 }455 if(match_ScenarioLine(context, token)) {456 endRule(context, 'DataTable');457 endRule(context, 'Step');458 endRule(context, 'Scenario');459 endRule(context, 'Scenario_Definition');460 startRule(context, 'Scenario_Definition');461 startRule(context, 'Scenario');462 build(context, token);463 return 2;464 }465 if(match_Comment(context, token)) {466 build(context, token);467 return 6;468 }469 if(match_Empty(context, token)) {470 build(context, token);471 return 6;472 }473 474 var stateComment = "State: 6 - GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:1>Step_Arg:0>__alt0:0>DataTable:0>#TableRow:0";475 token.detach();476 var expectedTokens = ["#EOF", "#TableRow", "#StepLine", "#TagLine", "#ScenarioLine", "#Comment", "#Empty"];477 var error = token.isEof ?478 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :479 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);480 if (self.stopAtFirstError) throw error;481 addError(context, error);482 return 6;483 }484 // GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:1>Step_Arg:0>__alt0:1>DocString:0>#DocStringSeparator:0485 function matchTokenAt_8(token, context) {486 if(match_DocStringSeparator(context, token)) {487 build(context, token);488 return 9;489 }490 if(match_Other(context, token)) {491 build(context, token);492 return 8;493 }494 495 var stateComment = "State: 8 - GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:1>Step_Arg:0>__alt0:1>DocString:0>#DocStringSeparator:0";496 token.detach();497 var expectedTokens = ["#DocStringSeparator", "#Other"];498 var error = token.isEof ?499 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :500 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);501 if (self.stopAtFirstError) throw error;502 addError(context, error);503 return 8;504 }505 // GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:1>Step_Arg:0>__alt0:1>DocString:2>#DocStringSeparator:0506 function matchTokenAt_9(token, context) {507 if(match_EOF(context, token)) {508 endRule(context, 'DocString');509 endRule(context, 'Step');510 endRule(context, 'Scenario');511 endRule(context, 'Scenario_Definition');512 build(context, token);513 return 7;514 }515 if(match_StepLine(context, token)) {516 endRule(context, 'DocString');517 endRule(context, 'Step');518 startRule(context, 'Step');519 build(context, token);520 return 5;...
Using AI Code Generation
1var matchTokenAt_9 = require('../lib/gherkin').matchTokenAt_9;2var tokenMatcher = require('../lib/gherkin').tokenMatcher;3var tokenType = require('../lib/gherkin').tokenType;4var gherkinLexer = require('../lib/gherkin').gherkinLexer;5var token = tokenType('FeatureLine');6var matched = matchTokenAt_9(token, 'Feature: A feature', 0);7var token = tokenType('ScenarioLine');8var matched = matchTokenAt_9(token, 'Scenario: A scenario', 0);9var matchTokenAt_10 = require('../lib/gherkin').matchTokenAt_10;10var tokenMatcher = require('../lib/gherkin').tokenMatcher;11var tokenType = require('../lib/gherkin').tokenType;12var gherkinLexer = require('../lib/gherkin').gherkinLexer;13var token = tokenType('FeatureLine');14var matched = matchTokenAt_10(token, 'Feature: A feature', 0);15var token = tokenType('ScenarioLine');16var matched = matchTokenAt_10(token, 'Scenario: A scenario', 0);17var matchTokenAt_11 = require('../lib/gherkin').matchTokenAt_11;18var tokenMatcher = require('../lib/gherkin').tokenMatcher;19var tokenType = require('../lib/gherkin').tokenType;20var gherkinLexer = require('../lib/gherkin').gherkinLexer;21var token = tokenType('FeatureLine');22var matched = matchTokenAt_11(token, 'Feature: A feature', 0);23var token = tokenType('ScenarioLine');24var matched = matchTokenAt_11(token, 'Scenario: A scenario', 0);25var matchTokenAt_12 = require('../lib/gherkin').matchTokenAt
Using AI Code Generation
1var gherkin = require('gherkin');2var fs = require('fs');3var path = require('path');4var feature = fs.readFileSync(path.join(__dirname, 'test.feature'), 'utf-8');5var lexer = new gherkin.Lexer('en');6var token = lexer.matchTokenAt_9(feature, 0);7console.log(token);8Error: No matching overloads found for matchTokenAt_9(str, pos), options are:9 matchTokenAt_9(str: string, pos: number): gherkin.Token10 matchTokenAt_9(str: string, pos: number, state: gherkin.LexerState): gherkin.Token11var sorted = list.sort(function(a, b) {12 return a.date - b.date;13});14 { date: new Date('2015-01-01') },15 { date: new Date('2015-01-02') },16 { date: new Date('2015-01-03') },17 { date: new Date('2015-01-04') }18];19 { date: '2015-01-01T00:00:00.000Z' },20 { date: '2015-01-02T00:00:00.000Z' },21 { date: '2015-01-03T00:00:00.000Z' },22 { date: '2015-01-04T00:00:00.000Z' }
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2var gherkin8 = require('cucumber-gherkin8');3var fs = require('fs');4var gherkinSource = fs.readFileSync('test.feature', 'utf-8');5var gherkinSource8 = fs.readFileSync('test8.feature', 'utf-8');6var parser = new gherkin.Parser();7var parser8 = new gherkin8.Parser();8var tokenMatcher = new gherkin.TokenMatcher();9var tokenMatcher8 = new gherkin8.TokenMatcher();10var tokenScanner = new gherkin.TokenScanner(gherkinSource);11var tokenScanner8 = new gherkin8.TokenScanner(gherkinSource8);12var tokenAt = tokenScanner.peek(0);13var tokenAt8 = tokenScanner8.peek(0);14var matchedToken = tokenMatcher.matchTokenAt_9(tokenAt, 0, tokenScanner);15var matchedToken8 = tokenMatcher8.matchTokenAt_8(tokenAt8, 0, tokenScanner8);16console.log(matchedToken);17console.log(matchedToken8);18{ type: 2, location: { line: 1, column: 1 }, text: 'Feature' }19{ type: 2, location: { line: 1, column: 1 }, text: 'Feature' }
Using AI Code Generation
1var Cucumber = require('cucumber');2var gherkin = require('gherkin');3Given test';4var gherkinParser = new gherkin.Parser();5var gherkinAst = gherkinParser.parse(gherkinSource);6var tokens = gherkinAst.feature.children[0].steps[0].text;7var token = Cucumber.TokenMatcher.matchTokenAt_9(tokens, 0, Cucumber.TokenType.GherkinStepKeyword);8console.log(token);9{ type: 'GherkinStepKeyword', location: { line: 3, column: 1 }, text: 'Given' }10The above code works with the latest version of cucumber.js (2.0.0-rc.7) and gherkin (4.1.3)
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2var fs = require('fs');3var gherkinSource = fs.readFileSync('sample.feature', 'utf8');4var gherkinDoc = gherkin.parse(gherkinSource);5var tokenAtPosition = gherkin.matchTokenAt_9(gherkinDoc, 0, 0, 0);6console.log(tokenAtPosition);7{ location: { line: 4, column: 1 },8 matchedText: 'a step' }9Your name to display (optional):
LambdaTest offers a detailed Cucumber testing tutorial, explaining its features, importance, best practices, and more to help you get started with running your automation testing scripts.
Here are the detailed Cucumber testing chapters to help you get started:
Get 100 minutes of automation test minutes FREE!!