diff options
Diffstat (limited to 'src/standard.php')
-rw-r--r-- | src/standard.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/standard.php b/src/standard.php new file mode 100644 index 0000000..6cc6be6 --- /dev/null +++ b/src/standard.php @@ -0,0 +1,35 @@ +<?php + +use Mnml\Lexer\Lexer; +use Mnml\Parser\Parser; + +$import = function (string $library) { + $input = file_get_contents(dirname(__FILE__) . "/" . $library); + $lexer = new Lexer($input); + $tokens = $lexer->lex(); + $parser = new Parser($tokens); + $nodes = $parser->parse(); +}; + +$print = function (string $string): void { + echo $string; +}; + +$dump = function (mixed $value): void { + var_dump($value); +}; + +$strlen = function (string $string) { + return strlen($string); +}; + +$get_char = function (string $input, int $position): string { + return $input[$position]; +}; + +$array_append = function (array $array, mixed $value): array { + $array[] = $value; + return $array; +}; + +return compact("import", "print", "dump", "strlen", "get_char", "array_append"); |