Last active
October 18, 2016 10:14
-
-
Save DmitrySoshnikov/1c43c52e97a4374b027da73d2d09cb48 to your computer and use it in GitHub Desktop.
using-calc-parser.php
This file contains hidden or 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 | |
require('CalcParser.php'); | |
var_dump(CalcParser::parse('2 + 2 * 2')); | |
/* | |
Result: | |
string(36) "Custom hook on parse begin. Parsing:" | |
string(9) "2 + 2 * 2" | |
string(33) "Custom hook on parse end. Parsed:" | |
object(BinaryExpression)#8 (4) { | |
["type"]=> | |
string(6) "Binary" | |
["left"]=> | |
object(PrimaryExpression)#4 (2) { | |
["type"]=> | |
string(7) "Primary" | |
["value"]=> | |
int(2) | |
} | |
["right"]=> | |
object(BinaryExpression)#7 (4) { | |
["type"]=> | |
string(6) "Binary" | |
["left"]=> | |
object(PrimaryExpression)#5 (2) { | |
["type"]=> | |
string(7) "Primary" | |
["value"]=> | |
int(2) | |
} | |
["right"]=> | |
object(PrimaryExpression)#6 (2) { | |
["type"]=> | |
string(7) "Primary" | |
["value"]=> | |
int(2) | |
} | |
["op"]=> | |
string(1) "*" | |
} | |
["op"]=> | |
string(1) "+" | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment