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.
24 lines
913 B
24 lines
913 B
<?php
|
|
/** @license MIT
|
|
* Copyright 2021 Dustin Wilson et al.
|
|
* See LICENSE file for details */
|
|
|
|
declare(strict_types=1);
|
|
namespace dW\Lit\Grammar;
|
|
|
|
abstract class NamedPatternListList extends ImmutableList {
|
|
public function __construct(array $array) {
|
|
/* This shit is here because PHP doesn't have array types or generics :) */
|
|
foreach ($array as $k => $v) {
|
|
if (!is_string($k)) {
|
|
throw new Exception(Exception::LIST_INVALID_TYPE, 'String', 'supplied array index', gettype($k));
|
|
}
|
|
|
|
if (!$v instanceof GrammarInclude && !$v instanceof Pattern && !$v instanceof PatternList) {
|
|
throw new Exception(Exception::LIST_INVALID_TYPE, __NAMESPACE__.'\GrammarInclude, '.__NAMESPACE__.'\Pattern, or '.__NAMESPACE__.'\PatternList', 'supplied array value', gettype($v));
|
|
}
|
|
}
|
|
|
|
$this->storage = $array;
|
|
}
|
|
}
|