From 7041d28eba92677463ef8b8080b317ee18df0f97 Mon Sep 17 00:00:00 2001 From: cristic Date: Fri, 23 Apr 2004 20:22:14 +0000 Subject: [PATCH] Grammar changes made today: G1. Got rid of literal(keyword) thing. Now we can simply use the keywords true, false, etc. G2. Added keywords NULL=null=0 G3. != works --- Repair/RepairCompiler/MCC/CDL.cup | 10 ++++++++-- Repair/RepairCompiler/MCC/Lexer.lex | 1 + Repair/RepairCompiler/MCC/MDL.cup | 11 +++++++++-- Repair/RepairCompiler/compiler-steps.txt | 25 +++++++++++++++++++----- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/Repair/RepairCompiler/MCC/CDL.cup b/Repair/RepairCompiler/MCC/CDL.cup index 76f769d..45c0e3f 100755 --- a/Repair/RepairCompiler/MCC/CDL.cup +++ b/Repair/RepairCompiler/MCC/CDL.cup @@ -472,7 +472,7 @@ expr ::= RESULT = expr; :} - | LITERAL OPENPAREN literal:literal CLOSEPAREN + | literal:literal {: debugMessage(PRODSTRING); ParseNode expr = new ParseNode("expr", parser.curLine(4)); @@ -596,6 +596,12 @@ literal ::= debugMessage(PRODSTRING); RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("boolean").addChild("false").getRoot(); :} + + | NULL + {: + debugMessage(PRODSTRING); + RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("decimal").addChild("0").getRoot(); + :} | DECIMAL:dec {: @@ -615,7 +621,7 @@ literal ::= RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("char").addChild(chr).getRoot(); :} - | ID:literal + | LITERAL OPENPAREN ID:literal CLOSEPAREN {: debugMessage(PRODSTRING); RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("token").addChild(literal).getRoot(); diff --git a/Repair/RepairCompiler/MCC/Lexer.lex b/Repair/RepairCompiler/MCC/Lexer.lex index b1a20f9..6e630c0 100755 --- a/Repair/RepairCompiler/MCC/Lexer.lex +++ b/Repair/RepairCompiler/MCC/Lexer.lex @@ -100,6 +100,7 @@ CHAR=(\\\"|\\\'|\\\\|\\t|\\n|[\x20-\x21\x23-\x26\x28-\x5B\x5D-\x7E]) cast { return tok(Sym.CAST, yytext()); } short { return tok(Sym.SHORT, yytext()); } null { return tok(Sym.NULL, yytext()); } + NULL { return tok(Sym.NULL, yytext()); } crash { return tok(Sym.CRASH, yytext()); } {ALPHA}({ALPHA}|{DIGIT})* { return tok(Sym.ID, yytext()); } diff --git a/Repair/RepairCompiler/MCC/MDL.cup b/Repair/RepairCompiler/MCC/MDL.cup index efd4942..4d2e02a 100755 --- a/Repair/RepairCompiler/MCC/MDL.cup +++ b/Repair/RepairCompiler/MCC/MDL.cup @@ -468,13 +468,14 @@ expr ::= RESULT = expr; :} - | LITERAL OPENPAREN literal:literal CLOSEPAREN + | literal:literal {: debugMessage(PRODSTRING); ParseNode expr = new ParseNode("expr", parser.curLine(4)); expr.addChild(literal); RESULT = expr; :} + | expr:leftexpr LT expr:rightexpr {: @@ -638,6 +639,12 @@ literal ::= debugMessage(PRODSTRING); RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("boolean").addChild("false").getRoot(); :} + + | NULL + {: + debugMessage(PRODSTRING); + RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("decimal").addChild("0").getRoot(); + :} | DECIMAL:dec {: @@ -657,7 +664,7 @@ literal ::= RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("char").addChild(chr).getRoot(); :} - | ID:literal + | LITERAL OPENPAREN ID:literal CLOSEPAREN {: debugMessage(PRODSTRING); RESULT = (new ParseNode("literal", parser.curLine(1))).addChild("token").addChild(literal).getRoot(); diff --git a/Repair/RepairCompiler/compiler-steps.txt b/Repair/RepairCompiler/compiler-steps.txt index f1b1173..7cb3689 100755 --- a/Repair/RepairCompiler/compiler-steps.txt +++ b/Repair/RepairCompiler/compiler-steps.txt @@ -29,11 +29,26 @@ A) copy the Runtime directory in Repair/Ex: cp -r /MCC/Runtime . B) copy generated files into the Runtime directory cp ex.cc ex_aux.* size.* Runtime -B) remove old object files +C) remove old object files cd Runtime; rm *.o -C) ./buildruntime -D) build checking object: +D) ./buildruntime +E) build checking object: g++ -g -c ex_aux.cc -E) If ex_test.c is the application under testing, run: + + +Step 4: Check the application +----------------------------- + +If ex_test.c is the application under testing, then: + +A) in ex_test.c, add: + #include "ex_aux.h" + #include "memory.h" +B) at the beginning of the main method, add: + initializemmap(); +C) wherever you want to check the consistency constraints, add: + #include "ex.cc" +D) compile the application: g++ -g ex_test.cc *.o -o ex_test -F) ./ex_test +E) run the application: + ./ex_test -- 2.34.1