// // // The Nimrod Compiler // (c) Copyright 2009 Andreas Rumpf // // See the file "copying.txt", included in this // distribution, for details about the copyright. // unit msgs; interface {$include 'config.inc'} uses nsystem, options, strutils, nos; //[[[cog //from string import replace //enum = "type\n TMsgKind = (\n" //msgs = "const\n MsgKindToStr: array [TMsgKind] of string = (\n" //warns = "const\n WarningsToStr: array [0..%d] of string = (\n" //hints = "const\n HintsToStr: array [0..%d] of string = (\n" //w = 0 # counts the warnings //h = 0 # counts the hints // //for elem in eval(open('data/messages.yml').read()): // for key, val in elem.items(): // enum = enum + ' %s,\n' % key // v = replace(val, "'", "''") // if key[0:4] == 'warn': // msgs = msgs + " '%s [%s]',\n" % (v, key[4:]) // warns = warns + " '%s',\n" % key[4:] // w = w + 1 // elif key[0:4] == 'hint': // msgs = msgs + " '%s [%s]',\n" % (v, key[4:]) // hints = hints + " '%s',\n" % key[4:] // h = h + 1 // else: // msgs = msgs + " '%s',\n" % v // //enum = enum[:-2] + ');\n\n' //msgs = msgs[:-2] + '\n );\n' //warns = (warns[:-2] + '\n );\n') % (w-1) //hints = (hints[:-2] + '\n );\n') % (h-1) // //cog.out(enum) //cog.out(msgs) //cog.out(warns) //cog.out(hints) //]]] type TMsgKind = ( errUnknown, errIllFormedAstX, errCannotOpenFile, errInternal, errGenerated, errXCompilerDoesNotSupportCpp, errStringLiteralExpected, errIntLiteralExpected, errInvalidCharacterConstant, errClosingTripleQuoteExpected, errClosingQuoteExpected, errTabulatorsAreNotAllowed, errInvalidToken, errLineTooLong, errInvalidNumber, errNumberOutOfRange, errNnotAllowedInCharacter, errClosingBracketExpected, errMissingFinalQuote, errIdentifierExpected, errOperatorExpected, errTokenExpected, errStringAfterIncludeExpected, errRecursiveDependencyX, errOnOrOffExpected, errNoneSpeedOrSizeExpected, errInvalidPragma, errUnknownPragma, errInvalidDirectiveX, errAtPopWithoutPush, errEmptyAsm, errInvalidIndentation, errExceptionExpected, errExceptionAlreadyHandled, errYieldNotAllowedHere, errInvalidNumberOfYieldExpr, errCannotReturnExpr, errAttemptToRedefine, errStmtInvalidAfterReturn, errStmtExpected, errInvalidLabel, errInvalidCmdLineOption, errCmdLineArgExpected, errCmdLineNoArgExpected, errInvalidVarSubstitution, errUnknownVar, errUnknownCcompiler, errOnOrOffExpectedButXFound, errNoneBoehmRefcExpectedButXFound, errNoneSpeedOrSizeExpectedButXFound, errGuiConsoleOrLibExpectedButXFound, errUnknownOS, errUnknownCPU, errGenOutExpectedButXFound, errArgsNeedRunOption, errInvalidMultipleAsgn, errColonOrEqualsExpected, errExprExpected, errUndeclaredIdentifier, errUseQualifier, errTypeExpected, errSystemNeeds, errExecutionOfProgramFailed, errNotOverloadable, errInvalidArgForX, errStmtHasNoEffect, errXExpectsTypeOrValue, errXExpectsArrayType, errIteratorCannotBeInstantiated, errExprXAmbiguous, errConstantDivisionByZero, errOrdinalTypeExpected, errOrdinalOrFloatTypeExpected, errOverOrUnderflow, errCannotEvalXBecauseIncompletelyDefined, errChrExpectsRange0_255, errDynlibRequiresExportc, errUndeclaredFieldX, errNilAccess, errIndexOutOfBounds, errIndexTypesDoNotMatch, errBracketsInvalidForType, errValueOutOfSetBounds, errFieldInitTwice, errFieldNotInit, errExprXCannotBeCalled, errExprHasNoType, errExprXHasNoType, errCast
"""Workaround to allow running single test cases directly"""
try:
from __init__ import init, Fake, OK, raise_ok
except:
from test import init, Fake, OK, raise_ok