Last active
September 5, 2020 14:43
-
-
Save divinity76/99d87dc396655b6432d1aae9e8882b7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$raw=<<<'RAW' | |
TEN = 10; | |
HUNDRED = 100; | |
THOUSAND = 1000; | |
MILLION = 1000000; | |
BILLION = 1000000000; | |
TRILLION = 1000000000000; | |
QUADRILLION = 1000000000000000; | |
QUINTILLION = 1000000000000000000; | |
INT64_MAX = 9223372036854775807; | |
UINT64_MAX = 18446744073709551615; | |
INT32_MAX = 2147483647; | |
UINT32_MAX = 4294967295; | |
RAW; | |
$raw=trim($raw); | |
foreach(explode("\n",$raw) as $line){ | |
$matches=[]; | |
preg_match('/^(?<name>[a-zA-Z0-9\_]+)\s*\=(?<spaces>\s*)(?<digits>\d+)\;\s*$/',$line,$matches); | |
$name=$matches["name"]; | |
$number=$matches["digits"]; | |
$spaces=$matches["spaces"]; | |
$name=strtolower($name); | |
echo "const uint64_t num_{$name} ={$spaces}uint64_t({$number});\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment