Changeset 3856
- Timestamp:
- Jul 18, 2008, 11:49:13 PM (13 years ago)
- Location:
- devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/compiler
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/compiler/ExprChecker.java
r3846 r3856 54 54 } 55 55 56 private final class ConstChecker implements ExprVisitorWithEnv<ContainerWithVar> { 57 public void visit (AstCall astCall, ContainerWithVar e) { 58 msgHandler.send(astCall.pos, MsgCode.UnexpectedFunctionCallInConst); 59 e.noError = false; 60 } 61 62 public void visit (AstCharSymbol astCharSymbol, ContainerWithVar e) {} 63 64 public void visit (AstExpr astExpr, ContainerWithVar e) { 65 ContainerWithVar e1 = new ContainerWithVar(); 66 for (AstTerm astTerm : astExpr.termList) 67 astTerm.accept(this, e1); 68 e.noError &= e1.noError; 69 } 70 71 public void visit (AstNumberSymbol astNumberSymbol, ContainerWithVar e) {} 72 73 public void visit (AstParen astParen, ContainerWithVar e) { 74 astParen.expr.accept(this, e); 75 } 76 77 public void visit (AstRef astRef, ContainerWithVar e) { 78 if (astRef.decl == null) 79 e.noError = false; 80 else if (astRef.decl instanceof AstConstBinding && !((AstConstBinding) astRef.decl).expr.noError) { 81 msgHandler.send(astRef.name.pos, MsgCode.UncheckedConstInConst); 82 e.noError = false; 83 } 84 } 85 86 public void visit (AstVar astVar, ContainerWithVar e) { 87 msgHandler.send(astVar.pos, MsgCode.UnexpectedVariableInConst); 88 e.noError = false; 89 } 90 91 public void visit (AstWordSymbol astWordSymbol, ContainerWithVar e) {} 92 } 93 56 94 private final class FormatChecker implements ExprVisitorWithEnv<ContainerWithVar> { 57 95 public void visit (AstCall astCall, ContainerWithVar e) { … … 161 199 } 162 200 201 private void checkConst (AstExpr astExpr) { 202 ContainerWithVar e = new ContainerWithVar(); 203 astExpr.accept(new ConstChecker(), e); 204 astExpr.noError = e.noError; 205 } 206 163 207 private void checkFormat (AstExpr astExpr) { 164 208 ContainerWithVar e = new ContainerWithVar(); … … 182 226 183 227 public void visit (AstConstBinding astConstBinding) { 184 check Format(astConstBinding.expr);228 checkConst(astConstBinding.expr); 185 229 } 186 230 -
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/compiler/MsgCode.java
r3566 r3856 43 43 TwoOccurrencesOfTheVariable_X_HaveDifferentTypes(Severity.Error, 44 44 "Two occurrences of the variable %s have different types"), // 45 UncheckedConstInConst(Severity.Error, "Unchecked constant reference in constant expression"), // 45 46 UnexpectedEndOfComment(Severity.Error, "Unexpected end of comment"), // 46 47 UnexpectedEndOfWord(Severity.Error, "Word literal is not properly closed by a double-quote"), // 47 48 UnexpectedEndOfCharacters(Severity.Error, "Characters literal is not properly closed by a single-quote"), // 49 UnexpectedFunctionCallInConst(Severity.Error, "Unexpected function call in constant expression"), // 48 50 UnexpectedFunctionCallInFormat(Severity.Error, "Unexpected function call in format"), // 49 51 UnexpectedFunctionCallInPattern(Severity.Error, "Unexpected function call in pattern"), // 50 52 UnexpectedToken(Severity.Error, "Unexpected token %s"), // 53 UnexpectedVariableInConst(Severity.Error, "Unexpected variable in constant expression"), // 51 54 // UnexpectedEOFInCharacterString(Severity.Error, "Unexpected EOF in character string"), // 52 55 // UnexpectedEOFInWord(Severity.Error, "Unexpected EOF in word"), //
Note: See TracChangeset
for help on using the changeset viewer.