tokenize - How to build a tokenizer in PHP? -
tokenize - How to build a tokenizer in PHP? -
i'm building site larn basic programming, i'm going utilize pseudolanguage in users can submit code , need interpret it. i'm not sure how build tokenizer in php.
having snippet such one:
a = 1 b = 2 c = - b if(a > b) { buy(a) } else { buy(b) }
how go separating code tokens?
--
this i'm trying now:
$tokens = array(); // first token (define string) $token = strtok($botcode, '='); $tokens[] = $token; // loop while($token) { $token = strtok('='); $tokens[] = $token; }
however haven't been able figure out how utilize strtok list of regular expresions... similar strtok accepts arrays needles substr , strrpos seems me should possible strtok it's designed this. info or pointing in right direction thanked
do not wait magic strtok. similar preg_split.
i think want build own lexer. utilize article writing simple lexer in php or something else.
php tokenize
Comments
Post a Comment