Advertisement
Guest User

P6opaque, Failure

a guest
Dec 30th, 2016
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. unit module Asistencia;
  2.  
  3. # Captura los presentes
  4.  
  5. grammar Asistencia {
  6. token TOP { ^ <link>**2 <html> $ }
  7.  
  8. token link { '<' <-[\>]>+ '>' \n }
  9.  
  10. token html { '<html>' \n <head> \n <body> }
  11. token head { '<head>' \n <meta> <title> <link> <style> '</head>' }
  12. token meta { '<META' <cont> '>' \n }
  13. token cont { <-[\>]>+ }
  14. token title { '<title>' <texto>+ '</title>' \n }
  15. token texto { <-[\<]>+ }
  16. token style { '<style>' <texto>+ '</style>' \n }
  17.  
  18. token body { '<body>' \n <div> <pre> .+ }
  19. token div { '<div' <-[\>]>+ '>' \n <p>+ \n '</div>' \n <p> \n }
  20. token p { '<p>' [<texto> [<span>||<br>]* \s*]+ '</p>' }
  21. token span { '<span' <cont> '>' <texto>? '</span>' }
  22. token br { '<br>' }
  23. token pre { '<ul class="asistencia-presentes">' \n [<li> \n]+ '</ul>' \n }
  24. token nota { '<i>' <texto> '</i>' }
  25. token li { '<li>' <texto> <nota>? '</li>' }
  26. }
  27.  
  28. class Asistencia-actions {
  29. method li ($/) { make $/.Str }
  30. }
  31.  
  32. for dir("$*HOME/Descargas/vozyvoto/asistencias-utf8") -> $documento {
  33. # fail with error: This type cannot unbox to a native integer: P6opaque, Failure
  34. my $m = Asistencia.parse($documento.IO.slurp, :actions(Asistencia-actions.new));
  35. say $m.made;
  36.  
  37. # this works for me
  38. # my $m = Asistencia.parse($documento.IO.slurp);
  39. # say $m<html><body><pre><li>>><texto>.Str;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement