Skip to content

Add PHP 8.1 explicit octal literal (0o / 0O) support - #5

Merged
TomasVotruba merged 1 commit into
mainfrom
add-php81-explicit-octal-literal
Oct 5, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
add-php81-explicit-octal-literal

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

The PHP 8 lexer defined hexadecimal (0x) and binary (0b) integer literals but not the PHP 8.1 explicit octal form 0o / 0O. On such input the scanner emitted 0 as T_LNUMBER followed by o... as T_STRING, producing a spurious parse error, e.g. umask(0o077) failed with unexpected T_STRING, expecting ')'.

Change

  • Add onum token definition and scanner rule in internal/php8/scanner.rl (base-8 parse, _ separators, overflow falls back to T_DNUMBER like the other bases).
  • Regenerate internal/php8/scanner.go via ragel.
  • Add TestExplicitOctalTokens.
  • Fix stale github.com/TomasVotruba/reco/pkg/token import left in scanner.rl after the module extraction, so regeneration produces the correct rectorphp/php-parser-in-go path.

Notes

The scanner.go diff is large because adding a token rule reshapes the generated ragel state machine. Full suite and golangci-lint pass.

@TomasVotruba
TomasVotruba merged commit ad2f1d0 into main Oct 5, 2026
5 checks passed
@TomasVotruba
TomasVotruba deleted the add-php81-explicit-octal-literal branch October 5, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant