mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-02 12:50:55 +00:00
Fix some overqualifications due to IDE renaming.
This commit is contained in:
parent
3545aa076f
commit
4aa516f0fb
@ -1,12 +1,13 @@
|
||||
package gay.pizza.pork.frontend
|
||||
|
||||
import gay.pizza.pork.parser.CharSource
|
||||
import gay.pizza.pork.parser.StringCharSource
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.absolutePathString
|
||||
import kotlin.io.path.readText
|
||||
|
||||
class FsContentSource(val root: Path) : ContentSource {
|
||||
override fun loadAsCharSource(path: String): gay.pizza.pork.parser.CharSource =
|
||||
override fun loadAsCharSource(path: String): CharSource =
|
||||
StringCharSource(asFsPath(path).readText())
|
||||
|
||||
override fun stableContentIdentity(path: String): String =
|
||||
|
@ -2,6 +2,7 @@ package gay.pizza.pork.frontend
|
||||
|
||||
import gay.pizza.pork.ast.CompilationUnit
|
||||
import gay.pizza.pork.ast.ImportDeclaration
|
||||
import gay.pizza.pork.parser.DiscardNodeAttribution
|
||||
import gay.pizza.pork.parser.Parser
|
||||
import gay.pizza.pork.parser.TokenStreamSource
|
||||
import gay.pizza.pork.parser.Tokenizer
|
||||
@ -18,7 +19,7 @@ class World(val contentSource: ContentSource) {
|
||||
val charSource = contentSource.loadAsCharSource(path)
|
||||
val tokenizer = Tokenizer(charSource)
|
||||
val tokenStream = tokenizer.tokenize()
|
||||
val parser = Parser(TokenStreamSource(tokenStream), gay.pizza.pork.parser.DiscardNodeAttribution)
|
||||
val parser = Parser(TokenStreamSource(tokenStream), DiscardNodeAttribution)
|
||||
return parser.readCompilationUnit()
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,9 @@ class Parser(source: PeekableSource<Token>, val attribution: NodeAttribution) {
|
||||
expect(TokenType.Func)
|
||||
val name = readSymbolRaw()
|
||||
expect(TokenType.LeftParentheses)
|
||||
val arguments = collect(TokenType.RightParentheses, TokenType.Comma) { readSymbolRaw() }
|
||||
val arguments = collect(TokenType.RightParentheses, TokenType.Comma) {
|
||||
readSymbolRaw()
|
||||
}
|
||||
expect(TokenType.RightParentheses)
|
||||
FunctionDefinition(modifiers, name, arguments, readBlock())
|
||||
}
|
||||
|
@ -2,12 +2,13 @@ package gay.pizza.pork.tool
|
||||
|
||||
import gay.pizza.pork.frontend.ContentSource
|
||||
import gay.pizza.pork.frontend.FsContentSource
|
||||
import gay.pizza.pork.parser.CharSource
|
||||
import gay.pizza.pork.parser.StringCharSource
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.readText
|
||||
|
||||
class FileTool(val path: Path) : Tool() {
|
||||
override fun createCharSource(): gay.pizza.pork.parser.CharSource = StringCharSource(path.readText())
|
||||
override fun createCharSource(): CharSource = StringCharSource(path.readText())
|
||||
override fun createContentSource(): ContentSource = FsContentSource(path.parent)
|
||||
override fun rootFilePath(): String = path.fileName.toString()
|
||||
}
|
||||
|
@ -3,12 +3,13 @@ package gay.pizza.pork.tool
|
||||
import com.github.ajalt.clikt.core.CliktCommand
|
||||
import com.github.ajalt.clikt.parameters.arguments.argument
|
||||
import com.github.ajalt.clikt.parameters.types.path
|
||||
import gay.pizza.pork.parser.AnsiHighlightScheme
|
||||
|
||||
class HighlightCommand : CliktCommand(help = "Syntax Highlighter", name = "highlight") {
|
||||
val path by argument("file").path(mustExist = true, canBeDir = false)
|
||||
|
||||
override fun run() {
|
||||
val tool = FileTool(path)
|
||||
print(tool.highlight(gay.pizza.pork.parser.AnsiHighlightScheme()).joinToString(""))
|
||||
print(tool.highlight(AnsiHighlightScheme()).joinToString(""))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user