Advertisement
Guest User

Untitled

a guest
May 28th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. ─> cat test
  2. grammar Foo {
  3. token TOP { <bottom> }
  4. token bottom { <?> }
  5. }
  6.  
  7. class Foo::Actions {
  8. method TOP($/) {
  9. my $grmr := Metamodel::GrammarHOW.new_type(name => 'BNFGrammar');
  10. $grmr.^add_method('TOP', token { <foo> });
  11. $grmr.^add_method('foo', $<bottom>.ast);
  12. $grmr.^compose;
  13. {
  14. my $/;
  15. say $grmr.new.parse('bar');
  16. }
  17. }
  18.  
  19. method bottom($/) {
  20. make token { "bar" }
  21. }
  22. }
  23.  
  24. Foo.new.parse('', :actions(Foo::Actions.new))
  25.  
  26. ─> perl6 test
  27. 「bar」
  28. foo => 「bar」
  29.  
  30. ─> diff -uN test test.fail
  31. --- test 2015-04-19 16:13:23.475552957 +0200
  32. +++ test.fail 2015-04-19 16:13:47.147928163 +0200
  33. @@ -7,7 +7,7 @@
  34. method TOP($/) {
  35. my $grmr := Metamodel::GrammarHOW.new_type(name => 'BNFGrammar');
  36. $grmr.^add_method('TOP', token { <foo> });
  37. - $grmr.^add_method('foo', $<bottom>.ast);
  38. + $grmr.^add_method('foo', $<bottom>.ast[0]);
  39. $grmr.^compose;
  40. {
  41. my $/;
  42. @@ -16,7 +16,7 @@
  43. }
  44.  
  45. method bottom($/) {
  46. - make token { "bar" }
  47. + make [token { "bar" }]
  48. }
  49. }
  50.  
  51. ─> perl6 test.fail
  52. Cannot find method 'postcircumfix:<( )>'
  53. in regex at test.fail:9
  54. in method parse at src/gen/m-CORE.setting:16692
  55. in method TOP at test.fail:14
  56. in regex TOP at test.fail:2
  57. in method parse at src/gen/m-CORE.setting:16692
  58. in block <unit> at test.fail:23
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement