TextMate-style syntax highlighting in PHP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

30 lines
735 B

<?php
/** @license MIT
* Copyright 2021 Dustin Wilson et al.
* See LICENSE file for details */
declare(strict_types=1);
namespace dW\Lit\Grammar;
use dW\Lit\Grammar;
/**
* Abstract class used as a base class for Pattern and Reference classes
*/
abstract class Rule {
use FauxReadOnly;
protected \WeakReference $_ownerGrammar;
public function __construct(Grammar $ownerGrammar) {
$this->_ownerGrammar = \WeakReference::create($ownerGrammar);
}
// Used when adopting to change the $ownerGrammar property.
public function withOwnerGrammar(Grammar $ownerGrammar): self {
$new = clone $this;
$new->_ownerGrammar = \WeakReference::create($ownerGrammar);
return $new;
}
}