修复IDE错误
This commit is contained in:
parent
c3c77345b7
commit
3411616870
@ -2,7 +2,6 @@ package org.jcnc.snow.compiler;
|
|||||||
|
|
||||||
import org.jcnc.snow.compiler.lexer.LexerEngine;
|
import org.jcnc.snow.compiler.lexer.LexerEngine;
|
||||||
import org.jcnc.snow.compiler.lexer.token.Token;
|
import org.jcnc.snow.compiler.lexer.token.Token;
|
||||||
import org.jcnc.snow.compiler.lexer.utils.TokenPrinter;
|
|
||||||
import org.jcnc.snow.compiler.parser.ParserEngine;
|
import org.jcnc.snow.compiler.parser.ParserEngine;
|
||||||
import org.jcnc.snow.compiler.parser.context.ParserContext;
|
import org.jcnc.snow.compiler.parser.context.ParserContext;
|
||||||
import org.jcnc.snow.compiler.parser.ast.base.Node;
|
import org.jcnc.snow.compiler.parser.ast.base.Node;
|
||||||
@ -28,6 +27,8 @@ public class Main {
|
|||||||
ParserContext ctx = new ParserContext(tokens);
|
ParserContext ctx = new ParserContext(tokens);
|
||||||
List<Node> ast = new ParserEngine(ctx).parse();
|
List<Node> ast = new ParserEngine(ctx).parse();
|
||||||
|
|
||||||
|
// 3. 语义分析
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 打印
|
// 打印
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析 if 语句:
|
* 解析 if 语句:
|
||||||
*
|
* <p>
|
||||||
* 支持格式:
|
* 支持格式:
|
||||||
* if <condition> then
|
* if <condition> then
|
||||||
* <then-statements>
|
* <then-statements>
|
||||||
|
|||||||
@ -203,8 +203,8 @@ public class JSONParser {
|
|||||||
if (currentChar() == '-') advance();
|
if (currentChar() == '-') advance();
|
||||||
while (isDigit(currentChar())) advance();
|
while (isDigit(currentChar())) advance();
|
||||||
if (currentChar() == '.') {
|
if (currentChar() == '.') {
|
||||||
advance();
|
do advance();
|
||||||
while (isDigit(currentChar())) advance();
|
while (isDigit(currentChar()));
|
||||||
}
|
}
|
||||||
if (currentChar() == 'e' || currentChar() == 'E') {
|
if (currentChar() == 'e' || currentChar() == 'E') {
|
||||||
advance();
|
advance();
|
||||||
@ -316,14 +316,13 @@ public class JSONParser {
|
|||||||
/**
|
/**
|
||||||
* 根据对象类型选择合适的写入方式
|
* 根据对象类型选择合适的写入方式
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static void writeValue(Object obj, StringBuilder sb) {
|
private static void writeValue(Object obj, StringBuilder sb) {
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
sb.append("null");
|
sb.append("null");
|
||||||
} else if (obj instanceof String) {
|
} else if (obj instanceof String) {
|
||||||
quote((String) obj, sb);
|
quote((String) obj, sb);
|
||||||
} else if (obj instanceof Number || obj instanceof Boolean) {
|
} else if (obj instanceof Number || obj instanceof Boolean) {
|
||||||
sb.append(obj.toString());
|
sb.append(obj);
|
||||||
} else if (obj instanceof Map) {
|
} else if (obj instanceof Map) {
|
||||||
sb.append('{');
|
sb.append('{');
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user