daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!perl
  2. #
  3. use strict;
  4. use warnings;
  5.  
  6. use Regexp::Grammars;
  7.  
  8. my $parser = qr/
  9. <nocontext:>
  10. ^<Statement>$
  11.  
  12. <rule: Statement> <Implication>
  13.  
  14. <rule: Implication> <L=Disjunction> -> <R=Implication> | <Disjunction>
  15.  
  16. <rule: Disjunction> <L=Conjunction> \|\| <R=Disjunction> | <Conjunction>
  17.  
  18. <rule: Conjunction> <L=Term> && <R=Conjunction> | <Term>
  19.  
  20. <rule: Term> <Variable> | \( <Statement> \)
  21.  
  22. <token: Variable> \w+
  23. /xms;
  24.  
  25. my $text = '(P || Q || R) && ((P -> R) -> Q)';
  26. use Data::Dumper;
  27. print Dumper($/{Statement}) if $text =~ $parser;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top