add println
This commit is contained in:
1 parent
215dc1426f
commit
ae29dd4e19
6 files changed
+11
-5
No files matched your search
@@ -1,7 +1,7 @@
|
||||
program->struct_declear program|declear program|calculation ; program|condition program|cycle program|array_declear program|print_func ; program|break_keyword ; program|$
|
||||
|
||||
|
||||
print_func->PRINT calculation GEQ_PRINT
|
||||
print_func->PRINT calculation GEQ_PRINT|PRINTLN calculation GEQ_PRINTLN
|
||||
|
||||
declear->type_name PUSH IDENTIFIER PUSH declear1
|
||||
declear1->; FILL|= declear2
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Main {
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
// System.out.println(result);
|
||||
System.out.println(result);
|
||||
|
||||
// System.out.println(Tables.SymbolTable);
|
||||
// System.out.println(Tables.quaternaryList);
|
||||
|
||||
@@ -191,6 +191,10 @@ abstract class LLParser {
|
||||
Symbol prntSym = semStack.pop();
|
||||
Tables.quaternaryList.add(new Quaternary("PRINT", "", "", prntSym.getValue()));
|
||||
break;
|
||||
case GEQ_PRINTLN:
|
||||
Symbol prntlnSym = semStack.pop();
|
||||
Tables.quaternaryList.add(new Quaternary("PRINTLN", "", "", prntlnSym.getValue()));
|
||||
break;
|
||||
case FILL_EMPTY_ARRAY:
|
||||
var emptyArrayCapacity = Integer.parseInt(capacityStack.pop().getValue());
|
||||
var arrayTypeSym = semStack.pop();
|
||||
|
||||
@@ -65,11 +65,13 @@ public class ParserGenerator {
|
||||
symbolString.add(new Symbol(sym, Symbol.ActionType.GEQ_CONTINUE));
|
||||
else if (sym.equals("GEQ_PRINT"))
|
||||
symbolString.add(new Symbol(sym, Symbol.ActionType.GEQ_PRINT));
|
||||
else if (sym.equals("GEQ_PRINTLN"))
|
||||
symbolString.add(new Symbol(sym, Symbol.ActionType.GEQ_PRINTLN));
|
||||
else if (sym.equals("BEGIN_STRUCT"))
|
||||
symbolString.add(new Symbol(sym, Symbol.ActionType.BEGIN_STRUCT));
|
||||
else if (sym.equals("END_STRUCT"))
|
||||
symbolString.add(new Symbol(sym, Symbol.ActionType.END_STRUCUT));
|
||||
else if(sym.equals("PUSH_MEMBER"))
|
||||
else if (sym.equals("PUSH_MEMBER"))
|
||||
symbolString.add(new Symbol(sym, Symbol.ActionType.PUSH_MEMBER));
|
||||
else if (ParserTest.isTerminal(sym))
|
||||
symbolString.add(new Symbol(sym, Symbol.SymbolType.Terminal));
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Symbol {
|
||||
, FILL_EMPTY_ARRAY //填空数组
|
||||
, PUSH_CAPACITY //将数组容量压栈
|
||||
, GEQ //生成运算四元式
|
||||
, GEQ_IF, END_IF, BEGIN_ELSE, GEQ_WHILE, END_WHILE, GEQ_PRINT, GEQ_BREAK, GEQ_CONTINUE, BEGIN_STRUCT, END_STRUCUT, PUSH_MEMBER
|
||||
, GEQ_IF, END_IF, BEGIN_ELSE, GEQ_WHILE, END_WHILE, GEQ_PRINTLN ,GEQ_PRINT, GEQ_BREAK, GEQ_CONTINUE, BEGIN_STRUCT, END_STRUCUT, PUSH_MEMBER
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
||||
@@ -15,7 +15,7 @@ public class StringSet {
|
||||
"goto",
|
||||
"if", "int",
|
||||
"long",
|
||||
"print",
|
||||
"print", "println",
|
||||
"register", "return",
|
||||
"short", "signed", "sizeof", "static", "struct", "switch",
|
||||
"typedef",
|
||||
|
||||
Reference in new issue
Block a user