Browse Source

Trying to figure out structure

main
Dustin Wilson 3 years ago
parent
commit
785c03b1f8
  1. 2
      README.md
  2. 4
      composer.json
  3. 12
      lib/Data.php
  4. 17
      lib/Highlight.php
  5. 17
      lib/Highlighter.php
  6. 2
      lib/Tokenizer.php

2
README.md

@ -4,4 +4,4 @@
# Lit #
Lit is a multilanguage syntax highlighter written in PHP. It takes code as input and returns HTML with classes based upon tokens in the code. It is loosely based upon [Atom][a]'s [Highlights][b] which is used in the Atom text editor to syntax highlight code. Atom's Highlights is in turn based upon [TextMate][c]'s syntax highlighting using its concepts of scope selectors and common classes for components of programming languages.
Lit is a multilanguage syntax highlighter written in PHP. It takes code as input and returns HTML with classes based upon tokens in the code. It is loosely based upon [Atom][a]'s [Highlights][b] which is used in the Atom text editor to syntax highlight code. Atom's Highlights is in turn based upon [TextMate][c]'s syntax highlighting using its concepts of scope selectors and common keywords for components of programming languages.

4
composer.json

@ -18,8 +18,8 @@
},
"autoload": {
"psr-4": {
"dW\\Highlighter\\": "lib/",
"dW\\Highlighter\\Scope\\": "lib/Scope/Matchers/"
"dW\\Lit\\": "lib/",
"dW\\Lit\\Scope\\": "lib/Scope/Matchers/"
}
}
}

12
lib/Grammar/Data.php → lib/Data.php

@ -4,10 +4,10 @@
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
namespace dW\Lit\Grammar;
namespace dW\Lit;
class Data {
public static function withFile(string $filepath): \Generator {
public static function fileToGenerator(string $filepath): \Generator {
$fp = fopen($filepath, 'r');
try {
while ($line = fgets($fp)) {
@ -18,10 +18,10 @@ class Data {
}
}
public static function withString(string $data): \Generator {
$data = explode("\n", $data);
foreach ($data as $d) {
yield $d;
public static function stringToGenerator(string $string): \Generator {
$string = explode("\n", $string);
foreach ($string as $s) {
yield $s;
}
}
}

17
lib/Highlight.php

@ -1,17 +0,0 @@
<?php
/** @license MIT
* Copyright 2021 Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
namespace dW\Lit;
class Highlight {
public static function withFile(string $filename): string {
$data = Grammar\Data::withFile($filename);
}
public static function withString(string $string): string {
$data = Grammar\Data::withString($string);
}
}

17
lib/Highlighter.php

@ -0,0 +1,17 @@
<?php
/** @license MIT
* Copyright 2021 Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
namespace dW\Lit;
class Highlighter {
public static function highlightFile(string $filepath, string $scopeName) {
$data = Data::fileToGenerator($filepath);
}
public static function highlightString(string $string, string $scopeName) {
$data = Data::stringToGenerator($string);
}
}

2
lib/Grammar/Tokenizer.php → lib/Tokenizer.php

@ -4,6 +4,6 @@
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
namespace dW\Lit\Grammar;
namespace dW\Lit;
class Tokenizer {}
Loading…
Cancel
Save