Changeset View
Changeset View
Standalone View
Standalone View
src/parser/PhutilParserGenerator.php
<?php | <?php | ||||
/** | /** | ||||
* Simple LR(1) parser generator. Generally, build a parser by setting terminals | * Simple LR(1) parser generator. Generally, build a parser by setting terminals | ||||
* and rules, then calling @{method:processGrammar}. For example, here is a | * and rules, then calling @{method:processGrammar}. For example, here is a | ||||
* simple grammar which accepts one or more "a" followed by exactly one "b": | * simple grammar which accepts one or more "a" followed by exactly one "b": | ||||
* | * | ||||
* $parser = id(new PhutilParserGenerator()) | * $parser = (new PhutilParserGenerator()) | ||||
* ->setTerminals(array('a', 'b')) | * ->setTerminals(array('a', 'b')) | ||||
* ->setStartRule('S') | * ->setStartRule('S') | ||||
* ->setRules( | * ->setRules( | ||||
* array( | * array( | ||||
* 'S' => 'A b', | * 'S' => 'A b', | ||||
* 'A' => array( | * 'A' => array( | ||||
* 'A a', | * 'A a', | ||||
* 'a', | * 'a', | ||||
▲ Show 20 Lines • Show All 894 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0