Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of http://github.com/ghnatiuk/consuming-gherkin

  • Loading branch information...
commit 542bc55e1666e8ffe31bdb015a23e221d1196291 2 parents 8c12b9f + b4b200d
Mike Sassak msassak authored
11 presentation/introduction/01_slide.md
Source Rendered
@@ -6,6 +6,17 @@
6 6 # Who We Are
7 7 ## Greg Hnatiuk & Mike Sassak
8 8
  9 +!SLIDE bullets incremental
  10 +# A Bit about Gherkin
  11 +* Language
  12 +* Parser
  13 +
  14 +!SLIDE
  15 +# Call to arms
  16 +
  17 +### "We need a faster parser. I'm currently looking at Ragel - a super fast state machine compiler. It's used by Mongrel, Thin, RedCloth and Hpricot to name a few, so it has a good track record in the Ruby community... Previous experience with Ragel is not a must, but definitely a plus."
  18 +## Aslak Hellesøy
  19 +
9 20 !SLIDE smaller
10 21 # Step
11 22 I18N_Step = ("Given " | "When " | "Then ") \
BIN  presentation/ragel_syntax/.01_slide.md.swp
Binary file not shown
128 presentation/ragel_syntax/01_slide.md
Source Rendered
@@ -172,6 +172,25 @@
172 172 end
173 173 * %%write exec
174 174
  175 +!SLIDE bullets
  176 + @@@ Ruby
  177 + class RagelTest
  178 + %%{
  179 + machine m;
  180 + action print_me { puts data[p].chr; }
  181 + Vowels = [aeiou] >print_me;
  182 + main := (Vowels | any)+;
  183 + }%%
  184 +
  185 + def initialize(str)
  186 + %%write data;
  187 + data = str.unpack("c*");
  188 + %%write init;
  189 + %%write exec;
  190 + end
  191 + end
  192 +* data and p
  193 +
175 194 !SLIDE center
176 195 ![parts_of_speech](parts_of_speech.png)
177 196
@@ -191,14 +210,60 @@
191 210 /text/
192 211 any, white, lower, alnum, digit
193 212
194   -!SLIDE bullets
195   -# Regular Language Operators
  213 +!SLIDE
  214 +# Operators
  215 +
  216 +!SLIDE bullets center
  217 +## Kleene star
  218 + @@@ Ruby
  219 + 'words'*
  220 +## One or more
  221 + @@@ Ruby
  222 + 'words'+
  223 +## Optional
  224 + @@@ Ruby
  225 + 'words'?
  226 +## Negation
  227 + @@@ Ruby
  228 + !'words'
  229 + ^'\n'
  230 +!SLIDE center
  231 +# Union
  232 + @@@ Ruby
  233 + 'foo' | 'bar'
  234 +!SLIDE center
  235 +# Intersection
  236 + @@@ Ruby
  237 + any{10} & [aeiou]
  238 +!SLIDE center
  239 +# Difference
  240 + @@@ Ruby
  241 + any+ - 'foo'
  242 +
  243 +!SLIDE center
  244 +# Concatenation
  245 + @@@ Ruby
  246 + [a-z]* . '\n'
  247 +
  248 +!SLIDE center
  249 +# Concatenation
  250 + @@@ Ruby
  251 + [a-z]* '\n'
  252 +
  253 +!SLIDE
  254 + @@@Ruby
  255 + EOL = ('\n' | '\r\n');
  256 +
  257 + Tag = ('@' [^@\r\n\t ]+);
  258 +
  259 + I18N_Step = ("* " | "Given " |
  260 + "When " | "Then " | "And " | "But ");
  261 +
  262 +!SLIDE center
  263 +### tokens = BOM? (space | EOL)* (Tags | Comment | FeatureHeading | BackgroundHeading | ScenarioHeading | ScenarioOutlineHeading | ExamplesH eading | Step | Row | PyString)* (space | EOL)* EOF;
196 264
197   -* Union
198   -* Intersection
199   -* Difference
200   -* Concatenation
201   -* Kleene star, etc... (*, +, ?, !)
  265 +!SLIDE
  266 +# So what?
202 267
203 268 !SLIDE bullets center
204 269 # Actions
@@ -249,7 +314,7 @@
249 314 !SLIDE center bullets
250 315 # Finishing Action
251 316 @@@ Ruby
252   - main := ('pon' 'y'+) @do_something
  317 + main := ('pon' 'y'+) @print_details
253 318
254 319 *
255 320
@@ -266,24 +331,51 @@
266 331
267 332 !SLIDE
268 333 # Guards and Nondeterminism
269   -!SLIDE bullets
270   -
271   -* finish-guarded
272   -* :>>
273 334
274 335 !SLIDE center
275 336 @@@ Ruby
276   - any* :>> 'STOP!'
  337 + any* 'No';
  338 +!SLIDE center bullets
  339 + @@@ Ruby
  340 + any* 'No';
  341 +*
  342 +![no_guard](no_guard.png)
277 343
278   -!SLIDE bullets
279   -* entry-guarded
280   -* :>
  344 +!SLIDE center bullets
  345 + @@@ Ruby
  346 + any* :>> 'No';
  347 +*
  348 +![guard](guard.png)
  349 +### Finish-guarded
  350 +
  351 +!SLIDE center bullets
281 352
282   -!SLIDE center
283 353 @@@ Ruby
284   - any* :> 'STOP!'
  354 + any* :> 'No';
  355 +*
  356 +![entryguard](entryguard.png)
  357 +### Entry-guarded
285 358
286 359 !SLIDE bullets
287 360 * left-guarded <:
288 361 * longest-match **
289 362 * named-priorities
  363 +
  364 +!SLIDE bullets
  365 + @@@ Ruby
  366 +
  367 + action begin_content {
  368 + @content_start = p
  369 + @current_line = @line_number
  370 + }
  371 +
  372 + action store_tag_content {
  373 + con = utf8_pack(data[@content_start...p])
  374 + @listener.tag(con, @curent_line)
  375 + }
  376 +
  377 + Tag = (('@' [^@\r\n\t ]+) >begin_content) \
  378 + %store_tag_content;
  379 +
  380 +!SLIDE center
  381 +![lexer_common](lexer_common.png)
BIN  presentation/ragel_syntax/entryguard.png
BIN  presentation/ragel_syntax/guard.png
BIN  presentation/ragel_syntax/lexer_common.png
BIN  presentation/ragel_syntax/no_guard.png
6 ragel/guards.rl
... ... @@ -0,0 +1,6 @@
  1 +%%{
  2 + machine m;
  3 +
  4 + main := any* <: 'No';
  5 +
  6 +}%%

0 comments on commit 542bc55

Please sign in to comment.
Something went wrong with that request. Please try again.