public TacticErrorReportingResolver(CompoundErrorInformation errorInfo)
        {
            Contract.Ensures(_errTok != null);
            Contract.Ensures(_errMessage != null);
            Contract.Ensures(_tacticCall != null);
            Contract.Ensures(_activeTactic != null);
            Contract.Ensures(_callingMember != null);
            Contract.Ensures(_tmpFailingMember != null);
            Contract.Ensures(!string.IsNullOrEmpty(_implTargetName));
            var proofState = errorInfo.S;
            var tmpProgram = ((CompoundErrorInformation)errorInfo.E).P;
            var innerError = ((CompoundErrorInformation)errorInfo.E).E;
            var tmpModule  = (DefaultClassDecl)tmpProgram.DefaultModuleDef.TopLevelDecls.FirstOrDefault(x => x.CompileName == "__default");

            var tok = innerError.Tok as NestedToken;

            _errTok     = tok != null ? (Bpl.Token)tok.Inner : (Bpl.Token)innerError.Tok;
            _errMessage = innerError.FullMsg;

            _implTargetName = MethodNameFromImpl(innerError.ImplementationName);
            _tacticCall     = proofState.TacticApplication;
            _activeTactic   = proofState.GetTactic(_tacticCall) as Tactic;

            _callingMember    = proofState.TargetMethod;
            _tmpFailingMember = tmpModule?.Members.FirstOrDefault(x => x.CompileName == _implTargetName);

            FailingLine = FailingCol = TacticLine = TacticCol = CallingLine = CallingCol = -1;

            if (!ActiveTacticWasNotUsed())
            {
                ResolveCorrectLocations();
            }
        }
    public TacticErrorReportingResolver(Tacny.CompoundErrorInformation errorInfo)
    {
      Contract.Ensures(_errTok != null);
      Contract.Ensures(_errMessage != null);
      Contract.Ensures(_tacticCall != null);
      Contract.Ensures(_activeTactic != null);
      Contract.Ensures(_callingMember != null);
      Contract.Ensures(_tmpFailingMember != null);
      Contract.Ensures(!string.IsNullOrEmpty(_implTargetName));
      var proofState = errorInfo.S;
      var tmpProgram = ((Tacny.CompoundErrorInformation)errorInfo.E).P;
      var innerError = ((Tacny.CompoundErrorInformation)errorInfo.E).E;
      var tmpModule = (DefaultClassDecl)tmpProgram.DefaultModuleDef.TopLevelDecls.FirstOrDefault();

      _errTok = (Bpl.Token)innerError.Tok;
      _errMessage = innerError.FullMsg;

      _implTargetName = MethodNameFromImpl(innerError.ImplementationName);
      _tacticCall = proofState.TacticApplication;
      _activeTactic = proofState.GetTactic(_tacticCall) as Tactic;

      _callingMember = proofState.TargetMethod;
      _tmpFailingMember = tmpModule?.Members.FirstOrDefault(x => x.CompileName == _implTargetName);

      FailingLine = FailingCol = TacticLine = TacticCol = CallingLine = CallingCol = -1;

      if(!ActiveTacticWasNotUsed()) ResolveCorrectLocations();
    }
Esempio n. 3
0
        /// <summary>
        /// Dafny comes with it's own copy of z3, to save new users the trouble of having to install extra dependency.
        /// For this to work, Dafny makes the Z3ExecutablePath point to the path were Z3 is put by our release script.
        /// For developers though (and people getting this from source), it's convenient to be able to run right away,
        /// so we vendor a Windows version.
        /// </summary>
        private void SetZ3ExecutableName()
        {
            var platform = (int)System.Environment.OSVersion.Platform;

            // http://www.mono-project.com/docs/faq/technical/
            var isUnix = platform == 4 || platform == 6 || platform == 128;

            var z3binName   = isUnix ? "z3" : "z3.exe";
            var dafnyBinDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var z3BinDir    = System.IO.Path.Combine(dafnyBinDir, "z3", "bin");
            var z3BinPath   = System.IO.Path.Combine(z3BinDir, z3binName);

            if (!System.IO.File.Exists(z3BinPath) && !isUnix)
            {
                // This is most likely a Windows user running from source without downloading z3
                // separately; this is ok, since we vendor z3.exe.
                z3BinPath = System.IO.Path.Combine(dafnyBinDir, z3binName);
            }

            if (!System.IO.File.Exists(z3BinPath) && errorReporter != null)
            {
                var tok = new Bpl.Token(1, 1)
                {
                    filename = "*** "
                };
                errorReporter.Warning(MessageSource.Other, tok, "Could not find '{0}' in '{1}'.{2}Downloading and extracting a Z3 distribution to Dafny's 'Binaries' folder would solve this issue; for now, we'll rely on Boogie to find Z3.",
                                      z3binName, z3BinDir, System.Environment.NewLine);
            }
            else
            {
                Z3ExecutablePath = z3BinPath;
            }
        }
Esempio n. 4
0
File: Dare.cs Progetto: ggrov/tacny
        public static List <DareResult> GetTokens(SimplificationData simpData)
        {
            var removableTokenData = new List <DareResult>();

            foreach (var removableAssert in simpData.RemovableAsserts)
            {
                removableTokenData.Add(new DareResult(removableAssert.Tok, removableAssert.EndTok, "Assert Statement"));
            }
            foreach (var invariant in simpData.RemovableInvariants)
            {
                removableTokenData.Add(new DareResult(invariant.E.tok, GetExpressionLength(invariant.E) + "invariant ".Length, "Invariant"));
            }
            foreach (var removableDecrease in simpData.RemovableDecreases)
            {
                removableTokenData.Add(new DareResult(removableDecrease.tok, GetExpressionLength(removableDecrease) + "decreases ".Length, "Decreases Expression"));
            }
            foreach (var removableLemmaCall in simpData.RemovableLemmaCalls)
            {
                int nameLength;
                try {
                    nameLength = (((removableLemmaCall.Rhss[0] as ExprRhs).Expr as ApplySuffix).Lhs as NameSegment).Name.Length;
                }
                catch (Exception) {
                    Console.WriteLine("Failed to find start token of lemmaCall");
                    continue;
                }
                var startToken = new Bpl.Token(removableLemmaCall.Tok.line, removableLemmaCall.Tok.col - nameLength);
                startToken.pos = removableLemmaCall.Tok.pos - nameLength;
                removableTokenData.Add(new DareResult(startToken, removableLemmaCall.EndTok, "Lemma Call"));
            }
            foreach (var removableCalc in simpData.RemovableCalcs)
            {
                removableTokenData.Add(new DareResult(removableCalc.Tok, removableCalc.EndTok, "Calc Statement"));
            }

            // This way will return the calc statement so it can be replaced
            foreach (var calcStmt in simpData.SimplifiedCalcs.Item4)
            {
                removableTokenData.Add(new DareResult(calcStmt.Tok, calcStmt.EndTok, "Calc Statement", calcStmt));
            }

            //this way will return the lines and hints -- commented out as there are issues getting the CalcOp

//            foreach (var line in simpData.SimplifiedCalcs.Item1)
//                removableTokenData.Add(new DareResult(line.tok, GetExpressionLength(line), "Calc Line"));
//            foreach (var hint in simpData.SimplifiedCalcs.Item2)
//                removableTokenData.Add(new DareResult(hint.Tok, hint.EndTok, "CalcStmt Hint"));

            foreach (var simplifiedAssert in simpData.SimplifiedAsserts)
            {
                removableTokenData.Add(new DareResult(simplifiedAssert.Item1.Tok, simplifiedAssert.Item1.EndTok, "Assert Statement", simplifiedAssert.Item2));
            }
            foreach (var simplifiedInvariant in simpData.SimplifiedInvariants)
            {
                removableTokenData.Add(new DareResult(simplifiedInvariant.Item1.E.tok, GetExpressionLength(simplifiedInvariant.Item1.E) + "invariant ".Length, "Invariant", simplifiedInvariant.Item2));
            }
            return(removableTokenData);
        }
Esempio n. 5
0
        public static IToken NextToken(IToken start = null, IToken end = null)
        {
            IToken ntok = new Microsoft.Boogie.Token(_idx, _idx);

            if (start != null & end != null)
            {
                var tup = new Tuple <IToken, IToken>(start, end);
                _tokens = x => x == _idx ? tup : _tokens(x);
            }
            _idx--;
            return(ntok);
        }
Esempio n. 6
0
        public override void ReportBplError(IToken tok, string message, bool error, TextWriter tw, string category = null)
        {
            // Dafny has 0-indexed columns, but Boogie counts from 1
              var realigned_tok = new Token(tok.line, tok.col - 1);
              realigned_tok.kind = tok.kind;
              realigned_tok.pos = tok.pos;
              realigned_tok.val = tok.val;
              realigned_tok.filename = tok.filename;
              base.ReportBplError(realigned_tok, message, error, tw, category);

              if (tok is Dafny.NestedToken) {
            var nt = (Dafny.NestedToken)tok;
            ReportBplError(nt.Inner, "Related location", false, tw);
              }
        }
Esempio n. 7
0
	Token/*!*/ NextToken() {
	  Contract.Ensures(Contract.Result<Token>() != null);
		while (ch == ' ' ||
			ch >= 9 && ch <= 10 || ch == 13
		) NextCh();
		if (ch == '/' && Comment0() ||ch == '/' && Comment1()) return NextToken();
		int apx = 0;
		int recKind = noSym;
		int recEnd = pos;
		t = new Token();
		t.pos = pos; t.col = col; t.line = line;
		t.filename = this.Filename;
		int state;
		if (start.ContainsKey(ch)) {
			Contract.Assert(start[ch] != null);
			state = (int) start[ch];
		}
		else { state = 0; }
		tlen = 0; AddCh();

		switch (state) {
			case -1: { t.kind = eofSym; break; } // NextCh already done
			case 0: {
				if (recKind != noSym) {
					tlen = recEnd - t.pos;
					SetScannerBehindT();
				}
				t.kind = recKind; break;
			} // NextCh already done
			case 1:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 1;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 2:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 2;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 3:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 3;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 4:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 4;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 5:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 5;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 6:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 6;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 7:
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 8;}
				else {goto case 0;}
			case 8:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 8;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 9:
				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 10;}
				else {goto case 0;}
			case 10:
				recEnd = pos; recKind = 3;
				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 10;}
				else if (ch == '_') {AddCh(); goto case 11;}
				else {t.kind = 3; break;}
			case 11:
				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 10;}
				else {goto case 0;}
			case 12:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 13;}
				else {goto case 0;}
			case 13:
				recEnd = pos; recKind = 4;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 13;}
				else if (ch == '_') {AddCh(); goto case 14;}
				else {t.kind = 4; break;}
			case 14:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 13;}
				else {goto case 0;}
			case 15:
				if (ch == 39) {AddCh(); goto case 20;}
				else {goto case 0;}
			case 16:
				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 17;}
				else {goto case 0;}
			case 17:
				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 18;}
				else {goto case 0;}
			case 18:
				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 19;}
				else {goto case 0;}
			case 19:
				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 15;}
				else {goto case 0;}
			case 20:
				{t.kind = 19; break;}
			case 21:
				if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '[' || ch >= ']' && ch <= 65535) {AddCh(); goto case 21;}
				else if (ch == '"') {AddCh(); goto case 28;}
				else if (ch == 92) {AddCh(); goto case 55;}
				else {goto case 0;}
			case 22:
				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 23;}
				else {goto case 0;}
			case 23:
				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 24;}
				else {goto case 0;}
			case 24:
				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 25;}
				else {goto case 0;}
			case 25:
				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {AddCh(); goto case 21;}
				else {goto case 0;}
			case 26:
				if (ch == '"') {AddCh(); goto case 27;}
				else {goto case 0;}
			case 27:
				if (ch <= '!' || ch >= '#' && ch <= 65535) {AddCh(); goto case 27;}
				else if (ch == '"') {AddCh(); goto case 56;}
				else {goto case 0;}
			case 28:
				{t.kind = 20; break;}
			case 29:
				{t.kind = 22; break;}
			case 30:
				{t.kind = 24; break;}
			case 31:
				{t.kind = 25; break;}
			case 32:
				{t.kind = 26; break;}
			case 33:
				{t.kind = 28; break;}
			case 34:
				{t.kind = 29; break;}
			case 35:
				{t.kind = 30; break;}
			case 36:
				{t.kind = 46; break;}
			case 37:
				{t.kind = 47; break;}
			case 38:
				{t.kind = 48; break;}
			case 39:
				{t.kind = 49; break;}
			case 40:
				{t.kind = 50; break;}
			case 41:
				{t.kind = 51; break;}
			case 42:
				{t.kind = 55; break;}
			case 43:
				{t.kind = 56; break;}
			case 44:
				{t.kind = 57; break;}
			case 45:
				if (ch == 'n') {AddCh(); goto case 46;}
				else {goto case 0;}
			case 46:
				if (ch <= '&' || ch >= '(' && ch <= '/' || ch >= ':' && ch <= '>' || ch == '@' || ch >= '[' && ch <= '^' || ch == '`' || ch >= '{' && ch <= 65535) {apx++; AddCh(); goto case 47;}
				else {goto case 0;}
			case 47:
				{
					tlen -= apx;
					SetScannerBehindT();
					t.kind = 58; break;}
			case 48:
				{t.kind = 59; break;}
			case 49:
				recEnd = pos; recKind = 2;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 49;}
				else if (ch == '_') {AddCh(); goto case 57;}
				else if (ch == '.') {AddCh(); goto case 12;}
				else {t.kind = 2; break;}
			case 50:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'q' || ch >= 's' && ch <= 'z') {AddCh(); goto case 2;}
				else if (ch == 'r') {AddCh(); goto case 58;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 51:
				recEnd = pos; recKind = 1;
				if (ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 59;}
				else if (ch == 39) {AddCh(); goto case 60;}
				else if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '&' || ch >= '(' && ch <= '/' || ch >= ':' && ch <= '>' || ch == '@' || ch == '[' || ch >= ']' && ch <= '^' || ch == '`' || ch >= '{' && ch <= 65535) {AddCh(); goto case 15;}
				else if (ch == 92) {AddCh(); goto case 54;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 52:
				recEnd = pos; recKind = 2;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 49;}
				else if (ch == '_') {AddCh(); goto case 57;}
				else if (ch == 'x') {AddCh(); goto case 9;}
				else if (ch == '.') {AddCh(); goto case 12;}
				else {t.kind = 2; break;}
			case 53:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 53;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 54:
				if (ch == '"' || ch == 39 || ch == '0' || ch == 92 || ch == 'n' || ch == 'r' || ch == 't') {AddCh(); goto case 15;}
				else if (ch == 'u') {AddCh(); goto case 16;}
				else {goto case 0;}
			case 55:
				if (ch == '"' || ch == 39 || ch == '0' || ch == 92 || ch == 'n' || ch == 'r' || ch == 't') {AddCh(); goto case 21;}
				else if (ch == 'u') {AddCh(); goto case 22;}
				else {goto case 0;}
			case 56:
				recEnd = pos; recKind = 20;
				if (ch == '"') {AddCh(); goto case 27;}
				else {t.kind = 20; break;}
			case 57:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 49;}
				else {goto case 0;}
			case 58:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'q' || ch >= 's' && ch <= 'z') {AddCh(); goto case 3;}
				else if (ch == 'r') {AddCh(); goto case 61;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 59:
				recEnd = pos; recKind = 1;
				if (ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 62;}
				else if (ch == 39) {AddCh(); goto case 63;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 60:
				recEnd = pos; recKind = 1;
				if (ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 62;}
				else if (ch == 39) {AddCh(); goto case 7;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 61:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'b' && ch <= 'z') {AddCh(); goto case 4;}
				else if (ch == 'a') {AddCh(); goto case 64;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 62:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 8;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 63:
				recEnd = pos; recKind = 19;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 8;}
				else {t.kind = 19; break;}
			case 64:
				recEnd = pos; recKind = 1;
				if (ch == 39 || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'x' || ch == 'z') {AddCh(); goto case 5;}
				else if (ch == 'y') {AddCh(); goto case 65;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 65:
				recEnd = pos; recKind = 5;
				if (ch == 39 || ch == '0' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 6;}
				else if (ch >= '1' && ch <= '9') {AddCh(); goto case 66;}
				else {t.kind = 5; break;}
			case 66:
				recEnd = pos; recKind = 5;
				if (ch == 39 || ch == '?' || ch >= 'A' && ch <= 'Z' || ch == '_' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 53;}
				else if (ch >= '0' && ch <= '9') {AddCh(); goto case 66;}
				else {t.kind = 5; break;}
			case 67:
				{t.kind = 79; break;}
			case 68:
				{t.kind = 96; break;}
			case 69:
				{t.kind = 104; break;}
			case 70:
				{t.kind = 119; break;}
			case 71:
				{t.kind = 121; break;}
			case 72:
				{t.kind = 122; break;}
			case 73:
				{t.kind = 123; break;}
			case 74:
				{t.kind = 124; break;}
			case 75:
				{t.kind = 125; break;}
			case 76:
				{t.kind = 126; break;}
			case 77:
				{t.kind = 127; break;}
			case 78:
				{t.kind = 129; break;}
			case 79:
				if (ch == '&') {AddCh(); goto case 80;}
				else {goto case 0;}
			case 80:
				{t.kind = 130; break;}
			case 81:
				{t.kind = 131; break;}
			case 82:
				{t.kind = 132; break;}
			case 83:
				{t.kind = 133; break;}
			case 84:
				{t.kind = 135; break;}
			case 85:
				{t.kind = 136; break;}
			case 86:
				{t.kind = 138; break;}
			case 87:
				{t.kind = 141; break;}
			case 88:
				{t.kind = 142; break;}
			case 89:
				recEnd = pos; recKind = 21;
				if (ch == ':') {AddCh(); goto case 30;}
				else if (ch == '|') {AddCh(); goto case 31;}
				else if (ch == '=') {AddCh(); goto case 69;}
				else {t.kind = 21; break;}
			case 90:
				recEnd = pos; recKind = 23;
				if (ch == '|') {AddCh(); goto case 97;}
				else {t.kind = 23; break;}
			case 91:
				recEnd = pos; recKind = 27;
				if (ch == '.') {AddCh(); goto case 98;}
				else {t.kind = 27; break;}
			case 92:
				recEnd = pos; recKind = 74;
				if (ch == '>') {AddCh(); goto case 34;}
				else if (ch == '=') {AddCh(); goto case 99;}
				else {t.kind = 74; break;}
			case 93:
				recEnd = pos; recKind = 140;
				if (ch == '>') {AddCh(); goto case 35;}
				else {t.kind = 140; break;}
			case 94:
				recEnd = pos; recKind = 52;
				if (ch == '=') {AddCh(); goto case 100;}
				else {t.kind = 52; break;}
			case 95:
				recEnd = pos; recKind = 53;
				if (ch == '=') {AddCh(); goto case 71;}
				else {t.kind = 53; break;}
			case 96:
				recEnd = pos; recKind = 134;
				if (ch == '=') {AddCh(); goto case 42;}
				else if (ch == 'i') {AddCh(); goto case 45;}
				else {t.kind = 134; break;}
			case 97:
				recEnd = pos; recKind = 105;
				if (ch == '|') {AddCh(); goto case 83;}
				else {t.kind = 105; break;}
			case 98:
				recEnd = pos; recKind = 149;
				if (ch == '.') {AddCh(); goto case 48;}
				else {t.kind = 149; break;}
			case 99:
				recEnd = pos; recKind = 54;
				if (ch == '>') {AddCh(); goto case 76;}
				else {t.kind = 54; break;}
			case 100:
				recEnd = pos; recKind = 120;
				if (ch == '=') {AddCh(); goto case 101;}
				else {t.kind = 120; break;}
			case 101:
				recEnd = pos; recKind = 128;
				if (ch == '>') {AddCh(); goto case 74;}
				else {t.kind = 128; break;}

		}
		t.val = new String(tval, 0, tlen);
		return t;
	}
Esempio n. 8
0
 // This method required by the Parser
 internal void Error(MessageSource source, string filename, int line, int col, string msg)
 {
     var tok = new Token(line, col);
       tok.filename = filename;
       Error(source, tok, msg);
 }
Esempio n. 9
0
 public Tuple<Method,TypeApply> GetSeqBuildMethod(Type t, SeqTree tree, List<bool> elemDimensions)
 {
     
     
     if (elemDimensions.Count == 0)
     {
         return GetSeqMethod(t, "seq_Empty");
     }
     if (elemDimensions.Count == 2 && elemDimensions[0] && elemDimensions[1])
     {
         return GetSeqMethod(t, "seq_Append");
     }
     string op = "seq_" + SeqTree.TreeName(tree);
     DatatypeDecl seqDecl = FindDatatype("Seq");
     var tok = new Bpl.Token(0, 0);
     tok.filename = @"!\Seq.dfy";
     TypeApply tApp = Compile_SeqType((SeqType)t);
     Type dataType = new UserDefinedType(tok, "Seq", seqDecl, new List<Type> { ((SeqType)t).Arg });
     Type elemType = ((SeqType)t).Arg;
     Func<string,Type,Expression> idExpr = (x, typ) => {
         var e = new IdentifierExpr(tok, x);
         e.Type = typ;
         e.Var = new LocalVariable(tok, tok, x, typ, false);
         return e;
     };
     Func<string,List<Expression>,FunctionCallExpr> seqCall = (x, args) => {
         var seqOp = GetSeqOperation(t, x);
         FunctionCallExpr callExpr = new FunctionCallExpr(
             tok, "Seq_Empty", new ThisExpr(tok), tok, args);
         callExpr.Function = seqOp.Item1;
         callExpr.TypeArgumentSubstitutions = seqOp.Item2.typeArgs;
         return callExpr;
     };
     Expression empty = seqCall("Seq_Empty", new List<Expression> {});
     int varCount = 0;
     Func<SeqTree,Expression> resultRec = null;
     resultRec = (subtree) =>
     {
         if (subtree == null)
         {
             return idExpr("s" + (varCount++), dataType);
         }
         if (subtree.buildCount >= 0)
         {
             Expression build = empty;
             for (int i = 0; i < subtree.buildCount; i++)
             {
                 build = seqCall("Seq_Build", new List<Expression>
                     { build, idExpr("a" + (varCount++), elemType) });
             }
             return build;
         }
         else
         {
             return seqCall("Seq_Append", new List<Expression>
                 { resultRec(subtree.left), resultRec(subtree.right) });
         }
     };
     Expression result = resultRec(tree);
     Expression post = seqCall("Seq_Equal", new List<Expression> { idExpr("s", dataType), result });
     List<Statement> stmts = new List<Statement>();
     for (int i = elemDimensions.Count; i > 0;)
     {
         bool isFirst = (i == elemDimensions.Count);
         i--;
         if (elemDimensions[i])
         {
             if (isFirst)
             {
                 
                 stmts.Add(new AssignStmt(tok, tok, idExpr("s", dataType),
                     new ExprRhs(idExpr("s" + i, dataType))));
             }
             else
             {
                 // s := seq_Append(s9, s);
                 var selectExpr = new MemberSelectExpr(tok, new ThisExpr(tok), "seq_Append");
                 selectExpr.Member = FindMethod(selectExpr.MemberName);  // Manually resolve here
                 selectExpr.TypeApplication = new List<Type>() { elemType }; // Manually resolve here
                 selectExpr.Type = new InferredTypeProxy();  // Manually resolve here
                 
                 CallStmt callStmt = new CallStmt(tok, tok,
                     new List<Expression> {idExpr("s", dataType)},
                     selectExpr, new List<Expression>
                         { idExpr("s" + i, dataType), idExpr("s", dataType) });                                                        
                 stmts.Add(callStmt);
             }
         }
         else
         {
             if (isFirst)
             {
                 
                 DatatypeValue nil = new DatatypeValue(tok, "Seq", "Nil", new List<Expression>() {});
                 nil.Type = dataType;
                 nil.InferredTypeArgs = new List<Type> { elemType };
                 nil.Ctor = seqDecl.Ctors[0];
                 Util.Assert(nil.Ctor.Name == "Seq_Nil");
                 stmts.Add(new AssignStmt(tok, tok, idExpr("s", dataType), new ExprRhs(nil)));
             }
             // lemma_Seq_Cons(ai, s);
             var selectExpr = new MemberSelectExpr(tok, new ThisExpr(tok), "lemma_Seq_Cons");                
             selectExpr.Member = FindMethod(selectExpr.MemberName);   // Manually resolve here
             selectExpr.TypeApplication = new List<Type>() { elemType }; // Manually resolve here
             selectExpr.Type = new InferredTypeProxy();  // Manually resolve here
             
             CallStmt callStmt = new CallStmt(tok, tok,
                 new List<Expression> {},
                 selectExpr, new List<Expression>
                     { idExpr("a" + i, elemType), idExpr("s", dataType) });                                
             callStmt.IsGhost = true;
             stmts.Add(callStmt);
             
             DatatypeValue cons = new DatatypeValue(tok, "Seq", "Cons", new List<Expression>()
                 { idExpr("a" + i, elemType), idExpr("s", dataType) });
             cons.Type = dataType;
             cons.InferredTypeArgs = new List<Type> { elemType };
             cons.Ctor = seqDecl.Ctors[1];
             Util.Assert(cons.Ctor.Name == "Seq_Cons");
             stmts.Add(new AssignStmt(tok, tok, idExpr("s", dataType), new ExprRhs(cons)));
         }
     }
     BlockStmt body = new BlockStmt(tok, tok, stmts);
     List<Formal> ins = new List<Formal>();
     for (int i = 0; i < elemDimensions.Count; i++)
     {
         bool isSeq = elemDimensions[i];
         ins.Add(new Formal(tok, (isSeq ? "s" : "a") + i, isSeq ? dataType : elemType, true, false));
     }
     List<Formal> outs = new List<Formal> { new Formal(tok, "s", dataType, false, false) };
     List<MaybeFreeExpression> reqs = new List<MaybeFreeExpression>();
     List<MaybeFreeExpression> enss = new List<MaybeFreeExpression> { new MaybeFreeExpression(post) };
     Specification<FrameExpression> mods = new Specification<FrameExpression>(new List<FrameExpression>(), null);
     Specification<Expression> decs = new Specification<Expression>(new List<Expression>(), null);
     Attributes attrs = new Attributes("dafnycc_conservative_seq_triggers", new List<Expression>(), null);
     Method m = new Method(tok, op, true, false, tApp.typeParams, ins, outs, reqs, mods, enss, decs, body, attrs, tok);
     m.EnclosingClass = GetSeqMethod(t, "seq_Append").Item1.EnclosingClass;
     return Tuple.Create(m, Compile_Method(m, tApp.typeArgs));
 }
Esempio n. 10
0
 /*--------------------------------------------------------------------------*/
 public Parser(Scanner scanner, Errors errors)
 {
     this.scanner = scanner;
     this.errors = errors;
     Token tok = new Token();
     tok.val = "";
     this.la = tok;
     this.t = new Token(); // just to satisfy its non-null constraint
 }
Esempio n. 11
0
 public void Parse()
 {
     la = new Token();
     la.val = "";
     Get();
     Dafny();
     Expect(0);
 }
Esempio n. 12
0
        void DotSuffix(out IToken x, out IToken y)
        {
            Contract.Ensures(Contract.ValueAtReturn(out x) != null);
            x = Token.NoToken;
            y = null;

            Expect(27);
            if (la.kind == 1) {
            Get();
            x = t;
            } else if (la.kind == 2) {
            Get();
            x = t;
            } else if (la.kind == 4) {
            Get();
            x = t;
            int exponent = x.val.IndexOf('e');
            if (0 <= exponent) {
             // this is not a legal field/destructor name
             SemErr(x, "invalid DotSuffix");
            } else {
             int dot = x.val.IndexOf('.');
             if (0 <= dot) {
               y = new Token();
               y.pos = x.pos + dot + 1;
               y.val = x.val.Substring(dot + 1);
               x.val = x.val.Substring(0, dot);
               y.col = x.col + dot + 1;
               y.line = x.line;
               y.filename = x.filename;
               y.kind = x.kind;
             }
            }

            } else if (la.kind == 45) {
            Get();
            x = t;
            } else if (la.kind == 44) {
            Get();
            x = t;
            } else SynErr(242);
        }
Esempio n. 13
0
        void Get()
        {
            for (;;) {
            t = la;
            la = scanner.Scan();
            if (la.kind <= maxT) { ++errDist; break; }

            la = t;
            }
        }
Esempio n. 14
0
	// peek for the next token, ignore pragmas
	public Token/*!*/ Peek () {
	  Contract.Ensures(Contract.Result<Token>() != null);
		do {
			if (pt.next == null) {
				pt.next = NextToken();
			}
			pt = pt.next;
		} while (pt.kind > maxT); // skip pragmas

		return pt;
	}
Esempio n. 15
0
	public void Parse() {
		la = new Token();
		la.val = "";
		Get();
		BoogiePL();
		Expect(0);

		Expect(0);
	}
Esempio n. 16
0
    /// <summary>
    /// Dafny comes with it's own copy of z3, to save new users the trouble of having to install extra dependency. 
    /// For this to work, Dafny makes the Z3ExecutablePath point to the path were Z3 is put by our release script.
    /// For developers though (and people getting this from source), it's convenient to be able to run right away, 
    /// so we vendor a Windows version.
    /// </summary>
    private void SetZ3ExecutableName() {
      var platform = (int)System.Environment.OSVersion.Platform;

      // http://www.mono-project.com/docs/faq/technical/
      var isUnix = platform == 4 || platform == 128;
      
      var z3binName = isUnix ? "z3" : "z3.exe";
      var dafnyBinDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
      var z3BinDir = System.IO.Path.Combine(dafnyBinDir, "z3", "bin");
      var z3BinPath = System.IO.Path.Combine(z3BinDir, z3binName);

      if (!System.IO.File.Exists(z3BinPath) && !isUnix) {
        // This is most likely a Windows user running from source without downloading z3 
        // separately; this is ok, since we vendor z3.exe.
        z3BinPath = System.IO.Path.Combine(dafnyBinDir, z3binName);
      }
      
      if (!System.IO.File.Exists(z3BinPath) && errorReporter != null) {
        var tok = new Bpl.Token(1, 1) { filename = "*** " };
        errorReporter.Warning(MessageSource.Other, tok, "Could not find '{0}' in '{1}'.{2}Downloading and extracting a Z3 distribution to Dafny's 'Binaries' folder would solve this issue; for now, we'll rely on Boogie to find Z3.", 
          z3binName, z3BinDir, System.Environment.NewLine);
      } else {
        Z3ExecutablePath = z3BinPath;
      }
    }
Esempio n. 17
0
File: Dare.cs Progetto: ggrov/tacny
        public static List<DareResult> GetTokens(SimplificationData simpData)
        {
            var removableTokenData = new List<DareResult>();

            foreach (var removableAssert in simpData.RemovableAsserts)
                removableTokenData.Add(new DareResult(removableAssert.Tok, removableAssert.EndTok, "Assert Statement"));
            foreach (var invariant in simpData.RemovableInvariants) 
                removableTokenData.Add(new DareResult(invariant.E.tok, GetExpressionLength(invariant.E) + "invariant ".Length, "Invariant"));
            foreach (var removableDecrease in simpData.RemovableDecreases)
                removableTokenData.Add(new DareResult(removableDecrease.tok, GetExpressionLength(removableDecrease) + "decreases ".Length, "Decreases Expression"));
            foreach (var removableLemmaCall in simpData.RemovableLemmaCalls) {
                int nameLength;
                try {
                    nameLength = (((removableLemmaCall.Rhss[0] as ExprRhs).Expr as ApplySuffix).Lhs as NameSegment).Name.Length;
                }
                catch (Exception) {
                    Console.WriteLine("Failed to find start token of lemmaCall");
                    continue;
                }
                var startToken = new Bpl.Token(removableLemmaCall.Tok.line, removableLemmaCall.Tok.col - nameLength);
                startToken.pos = removableLemmaCall.Tok.pos - nameLength;
                removableTokenData.Add(new DareResult(startToken, removableLemmaCall.EndTok, "Lemma Call"));
            }
            foreach (var removableCalc in simpData.RemovableCalcs)
                removableTokenData.Add(new DareResult(removableCalc.Tok, removableCalc.EndTok, "Calc Statement"));

            // This way will return the calc statement so it can be replaced
            foreach (var calcStmt in simpData.SimplifiedCalcs.Item4)
                removableTokenData.Add(new DareResult(calcStmt.Tok, calcStmt.EndTok, "Calc Statement", calcStmt));

            //this way will return the lines and hints -- commented out as there are issues getting the CalcOp

//            foreach (var line in simpData.SimplifiedCalcs.Item1)
//                removableTokenData.Add(new DareResult(line.tok, GetExpressionLength(line), "Calc Line"));
//            foreach (var hint in simpData.SimplifiedCalcs.Item2)
//                removableTokenData.Add(new DareResult(hint.Tok, hint.EndTok, "CalcStmt Hint"));

            foreach (var simplifiedAssert in simpData.SimplifiedAsserts)
                removableTokenData.Add(new DareResult(simplifiedAssert.Item1.Tok, simplifiedAssert.Item1.EndTok, "Assert Statement", simplifiedAssert.Item2));
            foreach (var simplifiedInvariant in simpData.SimplifiedInvariants)
                removableTokenData.Add(new DareResult(simplifiedInvariant.Item1.E.tok, GetExpressionLength(simplifiedInvariant.Item1.E) + "invariant ".Length, "Invariant", simplifiedInvariant.Item2));
            return removableTokenData;
        }
Esempio n. 18
0
	void Init() {
		pos = -1; line = 1; col = 0;
		oldEols = 0;
		NextCh();
		if (ch == 0xEF) { // check optional byte order mark for UTF-8
			NextCh(); int ch1 = ch;
			NextCh(); int ch2 = ch;
			if (ch1 != 0xBB || ch2 != 0xBF) {
				throw new FatalError(String.Format("illegal byte order mark: EF {0,2:X} {1,2:X}", ch1, ch2));
			}
			buffer = new UTF8Buffer(buffer); col = 0;
			NextCh();
		}
		pt = tokens = new Token();  // first token is a dummy
	}
Esempio n. 19
0
//	[NotDelayed]
	public Scanner (Stream/*!*/ s, Errors/*!*/ errorHandler, string/*!*/ fullFilename, string/*!*/ fileName, bool useBaseName = false) : base() {
		Contract.Requires(s != null);
		Contract.Requires(errorHandler != null);
		Contract.Requires(fileName != null);
		pt = tokens = new Token();  // first token is a dummy
		t = new Token(); // dummy because t is a non-null field
		this._buffer = new Buffer(s, true);
		this.errorHandler = errorHandler;
		this.FullFilename = fullFilename;
		this.Filename = useBaseName? GetBaseName(fileName) : fileName;
		Init();
	}
Esempio n. 20
0
//	[NotDelayed]
	public Scanner (string/*!*/ fullFilename, string/*!*/ fileName, Errors/*!*/ errorHandler, bool useBaseName = false) : base() {
		Contract.Requires(fileName != null);
		Contract.Requires(errorHandler != null);
		this.errorHandler = errorHandler;
		pt = tokens = new Token();  // first token is a dummy
		t = new Token(); // dummy because t is a non-null field
		try {
			Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
			this._buffer = new Buffer(stream, false);
			this.FullFilename = fullFilename;
			Filename = useBaseName? GetBaseName(fileName): fileName;
			Init();
		} catch (IOException) {
			throw new FatalError("Cannot open file " + fileName);
		}
	}
Esempio n. 21
0
	// make sure that peeking starts at the current scan position
	public void ResetPeek () { pt = tokens; }
Esempio n. 22
0
	Token/*!*/ NextToken() {
	  Contract.Ensures(Contract.Result<Token>() != null);
		while (ch == ' ' ||
			ch >= 9 && ch <= 10 || ch == 13
		) NextCh();
		if (ch == '/' && Comment0() ||ch == '/' && Comment1()) return NextToken();
		int recKind = noSym;
		int recEnd = pos;
		t = new Token();
		t.pos = pos; t.col = col; t.line = line;
		t.filename = this.Filename;
		int state;
		if (start.ContainsKey(ch)) {
			Contract.Assert(start[ch] != null);
			state = (int) start[ch];
		}
		else { state = 0; }
		tlen = 0; AddCh();

		switch (state) {
			case -1: { t.kind = eofSym; break; } // NextCh already done
			case 0: {
				if (recKind != noSym) {
					tlen = recEnd - t.pos;
					SetScannerBehindT();
				}
				t.kind = recKind; break;
			} // NextCh already done
			case 1:
				if (ch >= '#' && ch <= '$' || ch == 39 || ch == '.' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch >= '^' && ch <= 'z' || ch == '~') {AddCh(); goto case 2;}
				else {goto case 0;}
			case 2:
				recEnd = pos; recKind = 1;
				if (ch >= '#' && ch <= '$' || ch == 39 || ch == '.' || ch >= '0' && ch <= '9' || ch == '?' || ch >= 'A' && ch <= 'Z' || ch >= '^' && ch <= 'z' || ch == '~') {AddCh(); goto case 2;}
				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
			case 3:
				if (ch == 'v') {AddCh(); goto case 4;}
				else {goto case 0;}
			case 4:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 5;}
				else {goto case 0;}
			case 5:
				recEnd = pos; recKind = 2;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 5;}
				else {t.kind = 2; break;}
			case 6:
				if (ch == '"') {AddCh(); goto case 7;}
				else if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '[' || ch >= ']' && ch <= 65535) {AddCh(); goto case 6;}
				else if (ch == 92) {AddCh(); goto case 47;}
				else {goto case 0;}
			case 7:
				{t.kind = 4; break;}
			case 8:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 9;}
				else {goto case 0;}
			case 9:
				recEnd = pos; recKind = 6;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 9;}
				else if (ch == 'e') {AddCh(); goto case 10;}
				else {t.kind = 6; break;}
			case 10:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 12;}
				else if (ch == '-') {AddCh(); goto case 11;}
				else {goto case 0;}
			case 11:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 12;}
				else {goto case 0;}
			case 12:
				recEnd = pos; recKind = 6;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 12;}
				else {t.kind = 6; break;}
			case 13:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 13;}
				else if (ch == 'e') {AddCh(); goto case 14;}
				else {goto case 0;}
			case 14:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 16;}
				else if (ch == '-') {AddCh(); goto case 15;}
				else {goto case 0;}
			case 15:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 16;}
				else {goto case 0;}
			case 16:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 16;}
				else if (ch == 'f') {AddCh(); goto case 17;}
				else {goto case 0;}
			case 17:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 18;}
				else {goto case 0;}
			case 18:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 18;}
				else if (ch == 'e') {AddCh(); goto case 19;}
				else {goto case 0;}
			case 19:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 20;}
				else {goto case 0;}
			case 20:
				recEnd = pos; recKind = 7;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 20;}
				else {t.kind = 7; break;}
			case 21:
				if (ch == 'a') {AddCh(); goto case 22;}
				else {goto case 0;}
			case 22:
				if (ch == 'N') {AddCh(); goto case 23;}
				else {goto case 0;}
			case 23:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 24;}
				else {goto case 0;}
			case 24:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 24;}
				else if (ch == 'e') {AddCh(); goto case 25;}
				else {goto case 0;}
			case 25:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 26;}
				else {goto case 0;}
			case 26:
				recEnd = pos; recKind = 7;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 26;}
				else {t.kind = 7; break;}
			case 27:
				if (ch == 'a') {AddCh(); goto case 28;}
				else {goto case 0;}
			case 28:
				if (ch == 'n') {AddCh(); goto case 29;}
				else {goto case 0;}
			case 29:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 30;}
				else {goto case 0;}
			case 30:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 30;}
				else if (ch == 'e') {AddCh(); goto case 31;}
				else {goto case 0;}
			case 31:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 32;}
				else {goto case 0;}
			case 32:
				recEnd = pos; recKind = 7;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 32;}
				else {t.kind = 7; break;}
			case 33:
				if (ch == 'o') {AddCh(); goto case 34;}
				else {goto case 0;}
			case 34:
				if (ch == 'o') {AddCh(); goto case 35;}
				else {goto case 0;}
			case 35:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 36;}
				else {goto case 0;}
			case 36:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 36;}
				else if (ch == 'e') {AddCh(); goto case 37;}
				else {goto case 0;}
			case 37:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 38;}
				else {goto case 0;}
			case 38:
				recEnd = pos; recKind = 7;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 38;}
				else {t.kind = 7; break;}
			case 39:
				if (ch == 'o') {AddCh(); goto case 40;}
				else {goto case 0;}
			case 40:
				if (ch == 'o') {AddCh(); goto case 41;}
				else {goto case 0;}
			case 41:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 42;}
				else {goto case 0;}
			case 42:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 42;}
				else if (ch == 'e') {AddCh(); goto case 43;}
				else {goto case 0;}
			case 43:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 44;}
				else {goto case 0;}
			case 44:
				recEnd = pos; recKind = 7;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 44;}
				else {t.kind = 7; break;}
			case 45:
				recEnd = pos; recKind = 3;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 45;}
				else if (ch == 'b') {AddCh(); goto case 3;}
				else if (ch == 'e') {AddCh(); goto case 48;}
				else if (ch == '.') {AddCh(); goto case 8;}
				else {t.kind = 3; break;}
			case 46:
				recEnd = pos; recKind = 3;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 45;}
				else if (ch == 'b') {AddCh(); goto case 3;}
				else if (ch == 'e') {AddCh(); goto case 48;}
				else if (ch == '.') {AddCh(); goto case 8;}
				else if (ch == 'N') {AddCh(); goto case 21;}
				else if (ch == 'n') {AddCh(); goto case 27;}
				else if (ch == '+') {AddCh(); goto case 33;}
				else if (ch == '-') {AddCh(); goto case 39;}
				else {t.kind = 3; break;}
			case 47:
				if (ch == '"') {AddCh(); goto case 49;}
				else if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '[' || ch >= ']' && ch <= 65535) {AddCh(); goto case 6;}
				else if (ch == 92) {AddCh(); goto case 47;}
				else {goto case 0;}
			case 48:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 50;}
				else if (ch == '-') {AddCh(); goto case 51;}
				else {goto case 0;}
			case 49:
				recEnd = pos; recKind = 4;
				if (ch == '"') {AddCh(); goto case 7;}
				else if (ch <= 9 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= '!' || ch >= '#' && ch <= '[' || ch >= ']' && ch <= 65535) {AddCh(); goto case 6;}
				else if (ch == 92) {AddCh(); goto case 47;}
				else {t.kind = 4; break;}
			case 50:
				recEnd = pos; recKind = 5;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 50;}
				else if (ch == 'f') {AddCh(); goto case 17;}
				else {t.kind = 5; break;}
			case 51:
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 50;}
				else {goto case 0;}
			case 52:
				{t.kind = 9; break;}
			case 53:
				{t.kind = 10; break;}
			case 54:
				{t.kind = 11; break;}
			case 55:
				{t.kind = 13; break;}
			case 56:
				{t.kind = 18; break;}
			case 57:
				{t.kind = 19; break;}
			case 58:
				{t.kind = 28; break;}
			case 59:
				{t.kind = 51; break;}
			case 60:
				{t.kind = 56; break;}
			case 61:
				{t.kind = 57; break;}
			case 62:
				{t.kind = 58; break;}
			case 63:
				{t.kind = 59; break;}
			case 64:
				{t.kind = 61; break;}
			case 65:
				if (ch == '&') {AddCh(); goto case 66;}
				else {goto case 0;}
			case 66:
				{t.kind = 62; break;}
			case 67:
				{t.kind = 63; break;}
			case 68:
				{t.kind = 64; break;}
			case 69:
				{t.kind = 65; break;}
			case 70:
				{t.kind = 68; break;}
			case 71:
				{t.kind = 69; break;}
			case 72:
				{t.kind = 70; break;}
			case 73:
				{t.kind = 71; break;}
			case 74:
				{t.kind = 72; break;}
			case 75:
				{t.kind = 73; break;}
			case 76:
				{t.kind = 74; break;}
			case 77:
				{t.kind = 79; break;}
			case 78:
				{t.kind = 80; break;}
			case 79:
				{t.kind = 82; break;}
			case 80:
				{t.kind = 86; break;}
			case 81:
				{t.kind = 87; break;}
			case 82:
				{t.kind = 90; break;}
			case 83:
				{t.kind = 92; break;}
			case 84:
				{t.kind = 94; break;}
			case 85:
				{t.kind = 95; break;}
			case 86:
				{t.kind = 96; break;}
			case 87:
				recEnd = pos; recKind = 76;
				if (ch >= '0' && ch <= '9') {AddCh(); goto case 13;}
				else {t.kind = 76; break;}
			case 88:
				recEnd = pos; recKind = 12;
				if (ch == '=') {AddCh(); goto case 59;}
				else if (ch == ':') {AddCh(); goto case 85;}
				else {t.kind = 12; break;}
			case 89:
				recEnd = pos; recKind = 20;
				if (ch == '=') {AddCh(); goto case 97;}
				else if (ch == ':') {AddCh(); goto case 72;}
				else {t.kind = 20; break;}
			case 90:
				recEnd = pos; recKind = 21;
				if (ch == '=') {AddCh(); goto case 70;}
				else {t.kind = 21; break;}
			case 91:
				recEnd = pos; recKind = 29;
				if (ch == '|') {AddCh(); goto case 81;}
				else {t.kind = 29; break;}
			case 92:
				recEnd = pos; recKind = 32;
				if (ch == '=') {AddCh(); goto case 98;}
				else {t.kind = 32; break;}
			case 93:
				recEnd = pos; recKind = 45;
				if (ch == '*') {AddCh(); goto case 78;}
				else {t.kind = 45; break;}
			case 94:
				recEnd = pos; recKind = 55;
				if (ch == '|') {AddCh(); goto case 68;}
				else if (ch == '{') {AddCh(); goto case 80;}
				else {t.kind = 55; break;}
			case 95:
				recEnd = pos; recKind = 81;
				if (ch == '=') {AddCh(); goto case 71;}
				else {t.kind = 81; break;}
			case 96:
				recEnd = pos; recKind = 75;
				if (ch == '+') {AddCh(); goto case 76;}
				else {t.kind = 75; break;}
			case 97:
				recEnd = pos; recKind = 67;
				if (ch == '=') {AddCh(); goto case 99;}
				else {t.kind = 67; break;}
			case 98:
				recEnd = pos; recKind = 66;
				if (ch == '>') {AddCh(); goto case 62;}
				else {t.kind = 66; break;}
			case 99:
				recEnd = pos; recKind = 60;
				if (ch == '>') {AddCh(); goto case 60;}
				else {t.kind = 60; break;}

		}
		t.val = new String(tval, 0, tlen);
		return t;
	}
Esempio n. 23
0
	// get the next token (possibly a token already seen during peeking)
	public Token/*!*/ Scan () {
	 Contract.Ensures(Contract.Result<Token>() != null);
		if (tokens.next == null) {
			return NextToken();
		} else {
			pt = tokens = tokens.next;
			return tokens;
		}
	}
Esempio n. 24
0
        void ConvertKeywordTokenToIdent()
        {
            var oldKind = la.kind;
              la.kind = _ident;

              // call CheckLiteral with la
              var origT = t;
              t = la;
              scanner.CheckLiteral();
              t = origT;

              if (la.kind != _ident) {
            // it has been changed by CheckLiteral, which means it was a keyword
            la.kind = _ident;  // convert it to an ident
              } else {
            // la was something other than a keyword
            la.kind = oldKind;
              }
        }