phpeggy
Version:
PHP target for Peggy parser generator
85 lines (78 loc) • 2.42 kB
JavaScript
"use strict";
module.exports = function(phpGlobalNamePrefixOrNamespaceEscaped) {
return [
`if (!\\class_exists("${phpGlobalNamePrefixOrNamespaceEscaped}pegExpectation", false)) {`,
" class pegExpectation",
" {",
" public function __construct(",
" public ?string $type = null,",
" public ?string $description = null,",
" public ?string $value = null,",
" public ?string $ignoreCase = null,",
" public ?string $unicode = null",
" ) {",
" }",
" }",
"}",
"",
`if (!\\class_exists("${phpGlobalNamePrefixOrNamespaceEscaped}pegCacheItem", false)) {`,
" class pegCacheItem",
" {",
" public function __construct(",
" public int $nextPos,",
" public mixed $result",
" ) {",
" }",
" }",
"}",
"",
`if (!\\class_exists("${phpGlobalNamePrefixOrNamespaceEscaped}pegCachedPosDetails", false)) {`,
" class pegCachedPosDetails",
" {",
" public function __construct(",
" public int $line = 1,",
" public int $column = 1,",
" public bool $seenCR = false",
" ) {",
" }",
" }",
"}",
"",
`if (!\\class_exists("${phpGlobalNamePrefixOrNamespaceEscaped}pegLocation", false)) {`,
" class pegLocation",
" {",
" public function __construct(",
" public string $source,",
" public pegPosition $start,",
" public pegPosition $end",
" ) {",
" }",
" }",
"}",
"",
`if (!\\class_exists("${phpGlobalNamePrefixOrNamespaceEscaped}pegPosition", false)) {`,
" class pegPosition",
" {",
" public function __construct(",
" public int $offset,",
" public int $line,",
" public int $column",
" ) {",
" }",
" }",
"}",
"",
`if (!\\class_exists("${phpGlobalNamePrefixOrNamespaceEscaped}pegRange", false)) {`,
" class pegRange",
" {",
" public function __construct(",
" public string $source,",
" public int $start,",
" public int $end",
" ) {",
" }",
" }",
"}",
"",
];
};