3v4l.org

run code in 500+ 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        ROPE_INIT                                         5  ~5      '%23'
          3        ROPE_ADD                                          1  ~5      ~5, '%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'
          4        ROPE_ADD                                          2  ~5      ~5, '%28%3F%26'
          5        ROPE_ADD                                          3  ~5      ~5, !1
          6        ROPE_END                                          4  ~4      ~5, '%29%23Aux'
          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                                             $9      
         13      > JMPZ                                                         $9, ->17
   25    14    >   FETCH_DIM_R                                          ~10     !3, 0
         15        VERIFY_RETURN_TYPE                                           ~10
         16      > RETURN                                                       ~10
   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.5.0


preferences:
174.43 ms | 1648 KiB | 15 Q