3v4l.org

run code in 300+ PHP versions simultaneously
<?php #BLM final class ABNFParser { private const ABNF_REGEX = <<<'REGEX' (?(DEFINE) (?<ALPHA>[A-Za-z]) (?<DIGIT>[0-9]) (?<SP>[\x20]) (?<WSP>[(?&SP)\x09]) (?<CR>\x0D) (?<LF>\x0A) (?<Repeat>(?:(?:(?&DIGIT)+(?:(?&DIGIT)*[\x2A](?&DIGIT)*)))) ) REGEX; public function parse(string $input, string $rule): ?string { // Build the query pattern dynamically based on the provided rule $pattern = sprintf('#%s(?&%s)#Aux', self::ABNF_REGEX, $rule); if (preg_match($pattern, $input, $matches)) { return $matches[0]; } return null; } } # Example Usage $parser = new ABNFParser(); $input = '2*4'; $rule = 'Repeat'; $parsedResult = $parser->parse($input, $rule); var_dump($parsedResult); // Outputs: string(3) "2*4"
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Agmbt
function name:  (null)
number of ops:  14
compiled vars:  !0 = $parser, !1 = $input, !2 = $rule, !3 = $parsedResult
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $4      'ABNFParser'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   36     3        ASSIGN                                                   !1, '2%2A4'
   37     4        ASSIGN                                                   !2, 'Repeat'
   38     5        INIT_METHOD_CALL                                         !0, 'parse'
          6        SEND_VAR_EX                                              !1
          7        SEND_VAR_EX                                              !2
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                                   !3, $9
   40    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class ABNFParser:
Function parse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Agmbt
function name:  parse
number of ops:  20
compiled vars:  !0 = $input, !1 = $rule, !2 = $pattern, !3 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   22     2        INIT_FCALL                                               'sprintf'
          3        SEND_VAL                                                 '%23%25s%28%3F%26%25s%29%23Aux'
          4        SEND_VAL                                                 '%28%3F%28DEFINE%29%0A++++%28%3F%3CALPHA%3E%5BA-Za-z%5D%29%0A++++%28%3F%3CDIGIT%3E%5B0-9%5D%29%0A++++%28%3F%3CSP%3E%5B%5Cx20%5D%29%0A++++%28%3F%3CWSP%3E%5B%28%3F%26SP%29%5Cx09%5D%29%0A++++%28%3F%3CCR%3E%5Cx0D%29%0A++++%28%3F%3CLF%3E%5Cx0A%29%0A++++%28%3F%3CRepeat%3E%28%3F%3A%28%3F%3A%28%3F%26DIGIT%29%2B%28%3F%3A%28%3F%26DIGIT%29%2A%5B%5Cx2A%5D%28%3F%26DIGIT%29%2A%29%29%29%29%0A%29'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !2, $4
   24     8        INIT_FCALL                                               'preg_match'
          9        SEND_VAR                                                 !2
         10        SEND_VAR                                                 !0
         11        SEND_REF                                                 !3
         12        DO_ICALL                                         $6      
         13      > JMPZ                                                     $6, ->17
   25    14    >   FETCH_DIM_R                                      ~7      !3, 0
         15        VERIFY_RETURN_TYPE                                       ~7
         16      > RETURN                                                   ~7
   28    17    > > RETURN                                                   null
   29    18*       VERIFY_RETURN_TYPE                                       
         19*     > RETURN                                                   null

End of function parse

End of class ABNFParser.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.44 ms | 1007 KiB | 16 Q