Advertisement
Guest User

Untitled

a guest
Jan 10th, 2020
192
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.49 KB | None
  1. grammar Number
  2. {
  3.    token TOP       { <SCALAR> }
  4.    token SCALAR    { ONE
  5.                      | TWO
  6.                      | THREE
  7.                      | FOUR
  8.                      { make $/.made; }
  9.              }
  10.  
  11.    # Termination tokens
  12.    token ONE        { one {make 1;}  }
  13.    token TWO        { two {make 2;}  }
  14.    token THREE      { three {make 3;} }
  15.    token FOUR       { four {make 4;}  }
  16. }
  17.  
  18.  
  19. for lines() {
  20.   my $match = Number.parse($_).made;
  21.   say $match<SCALAR>.made
  22. }
Advertisement
RAW Paste Data Copied
Advertisement