Merge branch 'maint/7.0'
[ninja.git] / src / op5 / ninja_sdk / parsegen / js / LalrPreprocessorJSGenerator.php
blobed8d21513fe983a12bf184389ff4033774879941
1 <?php
3 class LalrPreprocessorJSGenerator extends js_class_generator {
4 private $grammar;
6 public function __construct( $parser_name, $grammar ) {
7 $this->classname = $parser_name . "Preprocessor";
8 $this->grammar = $grammar->get_tokens();
11 public function generate($skip_generated_note = false) {
12 parent::generate($skip_generated_note);
14 $this->init_class();
15 foreach( $this->grammar as $name => $match ) {
16 if( $name[0] != '_' ) {
17 $this->generate_preprocessor( $name );
20 $this->finish_class();
23 private function generate_preprocessor( $name ) {
24 $this->init_function( 'preprocess_'.$name, array( 'value' ) );
25 $this->write( 'return value;' );
26 $this->finish_function();