Skip to content

Commit

Permalink
fix: add back support for txt / nameless language
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangjchandler committed Oct 8, 2024
1 parent 3814f3f commit b079071
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
10 changes: 8 additions & 2 deletions meta/stubs/DefaultGrammars.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ namespace Phiki\Grammar;

abstract class DefaultGrammars
{
final const array NAMES_TO_PATHS = [%s];
final const array NAMES_TO_PATHS = [
'txt' => __DIR__ . '/../../resources/languages/txt.json',
%s
];

final const array SCOPES_TO_NAMES = [%s];
final const array SCOPES_TO_NAMES = [
'text.txt' => 'txt',
%s
];
}
1 change: 1 addition & 0 deletions meta/stubs/Grammar.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use Phiki\Contracts\GrammarRepositoryInterface;

enum Grammar: string
{
case Txt = 'txt';
%s

public function toParsedGrammar(GrammarRepositoryInterface $repository): ParsedGrammar
Expand Down
14 changes: 10 additions & 4 deletions src/Grammar/DefaultGrammars.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

abstract class DefaultGrammars
{
final const array NAMES_TO_PATHS = ['astro' => __DIR__.'/../../resources/languages/astro.json',
final const array NAMES_TO_PATHS = [
'txt' => __DIR__.'/../../resources/languages/txt.json',
'astro' => __DIR__.'/../../resources/languages/astro.json',
'hy' => __DIR__.'/../../resources/languages/hy.json',
'nim' => __DIR__.'/../../resources/languages/nim.json',
'cpp' => __DIR__.'/../../resources/languages/cpp.json',
Expand Down Expand Up @@ -216,9 +218,12 @@ abstract class DefaultGrammars
'json5' => __DIR__.'/../../resources/languages/json5.json',
'cadence' => __DIR__.'/../../resources/languages/cadence.json',
'desktop' => __DIR__.'/../../resources/languages/desktop.json',
'asm' => __DIR__.'/../../resources/languages/asm.json'];
'asm' => __DIR__.'/../../resources/languages/asm.json',
];

final const array SCOPES_TO_NAMES = ['source.astro' => 'astro',
final const array SCOPES_TO_NAMES = [
'text.txt' => 'txt',
'source.astro' => 'astro',
'source.hy' => 'hy',
'source.nim' => 'nim',
'source.cpp' => 'cpp',
Expand Down Expand Up @@ -430,5 +435,6 @@ abstract class DefaultGrammars
'source.json5' => 'json5',
'source.cadence' => 'cadence',
'source.desktop' => 'desktop',
'source.asm.x86_64' => 'asm'];
'source.asm.x86_64' => 'asm',
];
}
1 change: 1 addition & 0 deletions src/Grammar/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

enum Grammar: string
{
case Txt = 'txt';
case Astro = 'astro';
case Hy = 'hy';
case Nim = 'nim';
Expand Down
2 changes: 0 additions & 2 deletions tests/Languages/HtmlTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php

use Phiki\Grammar\ParsedGrammar;
use Phiki\Phiki;
use Phiki\Token\Token;
use Phiki\Tokenizer;

describe('html', function () {
it('correctly tokenizes a basic tag', function () {
Expand Down
4 changes: 0 additions & 4 deletions tests/Languages/PhpTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<?php

use Phiki\Grammar\Grammar;
use Phiki\Grammar\GrammarRepository;
use Phiki\Grammar\ParsedGrammar;
use Phiki\Phiki;
use Phiki\Token\Token;
use Phiki\Tokenizer;

describe('php', function () {
it('correctly tokenizes a double-quoted string', function () {
Expand Down

0 comments on commit b079071

Please sign in to comment.