Skip to content

Commit

Permalink
[PHP] Add rudimentary example
Browse files Browse the repository at this point in the history
  • Loading branch information
lierdakil committed Jul 31, 2020
1 parent 9e896b4 commit a4cac3e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/polish-notation-calc/php/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lexer.*
parser.*
Lexer.*
Parser.*
*.txt
12 changes: 12 additions & 0 deletions examples/polish-notation-calc/php/main.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
namespace Alpaca;

require './Lexer.php';

$debug = $argv[1] == '-d';
while($f = fgets(STDIN)){
$lexer = new Lexer(rtrim($f), $debug);
while(($token = $lexer->getNextToken())[0] !== Lexer::TOKEN_TYPE_EOF) {
echo(Lexer::tokenToString($token[0]) . ", " . $token[1] . "\n");
}
}
4 changes: 4 additions & 0 deletions examples/polish-notation-calc/php/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

${alpaca:-alpaca} -l php $args syntax.xy &&\
php main.php "$@" <<< "$input"

0 comments on commit a4cac3e

Please sign in to comment.