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.
 
 

43 lines
918 B

<?php
/** @license MIT
* Copyright 2021 Dustin Wilson et al.
* See LICENSE file for details */
declare(strict_types=1);
namespace dW\Lit\Scope;
class Scope extends Node {
protected bool $_anchorToPrevious;
protected array $atoms = [];
protected bool $frozen = false;
public function __construct(Path $parent, bool $anchorToPrevious = false) {
$this->_anchorToPrevious = $anchorToPrevious;
$this->_parent = \WeakReference::create($parent);
}
public function add(string ...$atoms): bool {
if ($this->frozen) {
return false;
}
$this->atoms = $atoms;
$this->frozen = true;
return true;
}
public function __toString(): string {
$result = '';
if ($this->_anchorToPrevious) {
$result .= '< ';
}
$result .= implode('.', $this->_atoms);
return $result;
}
}