php-kilo/src/Syntax.php

46 lines
1.2 KiB
PHP
Raw Normal View History

2019-10-24 16:58:52 -04:00
<?php declare(strict_types=1);
2019-11-08 16:27:08 -05:00
namespace Aviat\Kilo;
2019-10-24 16:58:52 -04:00
class Syntax {
public const HIGHLIGHT_NUMBERS = (1 << 0);
2019-10-25 11:49:04 -04:00
public const HIGHLIGHT_STRINGS = (1 << 1);
2019-10-24 16:58:52 -04:00
// Tokens for PHP files
public array $tokens = [];
public static function new(
string $name,
array $keywords1 = [],
array $keywords2 = [],
string $slcs = '//',
string $mcs = '/*',
string $mce = '*/',
2021-03-16 18:37:53 -04:00
int $flags = self::HIGHLIGHT_NUMBERS | self::HIGHLIGHT_STRINGS,
): self
2019-10-24 16:58:52 -04:00
{
2021-03-17 15:38:52 -04:00
return new self($name, $keywords1, $keywords2, $slcs, $mcs, $mce, $flags);
2019-10-24 16:58:52 -04:00
}
2021-03-16 18:37:53 -04:00
public static function default(): self
{
return self::new('No filetype', slcs: '', mcs: '', mce: '', flags: 0);
}
private function __construct(
/** The name of the programming language */
public string $filetype,
/** Primary set of language keywords */
public array $keywords1,
/** Secondary set of language keywords */
public array $keywords2,
/** Syntax to start a single line comment */
public string $singleLineCommentStart,
/** Syntax to start a multi-line comment */
public string $multiLineCommentStart,
/** Syntax to end a multi-line commment */
2021-03-05 21:16:39 -05:00
public string $multiLineCommentEnd,
/** Bitflags configuring the specified language syntax */
public int $flags,
) {}
2019-10-24 16:58:52 -04:00
}