feat: 支持标准 URL 格式
This commit is contained in:
parent
3a2a1363e6
commit
3e7e5f2dad
@ -37,7 +37,7 @@ public class LexerEngine {
|
|||||||
* @param sourceName 文件名(诊断用)
|
* @param sourceName 文件名(诊断用)
|
||||||
*/
|
*/
|
||||||
public LexerEngine(String source, String sourceName) {
|
public LexerEngine(String source, String sourceName) {
|
||||||
this.absPath = new File(sourceName).getAbsolutePath();
|
this.absPath = new File(sourceName).getAbsolutePath().replace('\\', '/');
|
||||||
this.context = new LexerContext(source);
|
this.context = new LexerContext(source);
|
||||||
this.scanners = List.of(
|
this.scanners = List.of(
|
||||||
new WhitespaceTokenScanner(),
|
new WhitespaceTokenScanner(),
|
||||||
|
|||||||
@ -50,6 +50,6 @@ public class LexicalError {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return file + ":" + line + ":" + column + ": " + message;
|
return "file:///" + file + ":" + line + ":" + column + ": " + message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,6 @@ public class ParseError {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return file + ":" + line + ":" + column + ": " + message;
|
return "file:///" + file + ":" + line + ":" + column + ": " + message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public class ParserContext {
|
|||||||
*/
|
*/
|
||||||
public ParserContext(List<Token> tokens, String sourceName) {
|
public ParserContext(List<Token> tokens, String sourceName) {
|
||||||
this.tokens = new TokenStream(tokens);
|
this.tokens = new TokenStream(tokens);
|
||||||
this.sourceName = Paths.get(sourceName).toAbsolutePath().toString();
|
this.sourceName = Paths.get(sourceName).toAbsolutePath().toString().replace('\\', '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ public record SemanticError(Node node, String message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder("file:///");
|
||||||
if (file != null && !file.isBlank()) sb.append(file).append(":");
|
if (file != null && !file.isBlank()) sb.append(file).append(":");
|
||||||
sb.append((line >= 0 && col >= 0) ? line + ":" + col : "未知位置");
|
sb.append((line >= 0 && col >= 0) ? line + ":" + col : "未知位置");
|
||||||
sb.append(": ").append(message);
|
sb.append(": ").append(message);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user