Esempio n. 1
0
        private static IEnumerable<Error> ResolveRefType(RefType type, Node var)
        {
            var errors = new List<Error>();

            var actual = var.GetNearestParent<Program>().GetSubChildren<Record>().Where(x => x.Name.Text == type.Name.Text).ToList();
            if (actual.Count == 0)
                errors.Add(new Error(var.GetSourceIdentifier(), type.Name,
                                     string.Format(ErrorMessages.TypeNotFound, type.Name.Text)));
            if (actual.Count == 1)
                return errors;

            if (actual.Count > 1)
                errors.Add(new Error(var.GetSourceIdentifier(), type.Name,
                                     string.Format(ErrorMessages.MultipleTypeMatch, string.Join(";", actual))));

            return errors;
        }
Esempio n. 2
0
	public IType type()
	{
		EnterRule_type();
		EnterRule("type", 27);
		TraceIn("type", 27);
		IType type = default(IType);


		IToken INTEGER55 = default(IToken);
		IToken REAL56 = default(IToken);
		IToken identifier54 = default(IToken);

		try { DebugEnterRule(GrammarFileName, "type");
		DebugLocation(539, 5);
		try
		{
			// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:540:6: ( identifier | INTEGER | REAL )
			int alt30=3;
			try { DebugEnterDecision(30, false);
			switch (input.LA(1))
			{
			case ID:
				{
				alt30 = 1;
				}
				break;
			case INTEGER:
				{
				alt30 = 2;
				}
				break;
			case REAL:
				{
				alt30 = 3;
				}
				break;
			default:
				{
					NoViableAltException nvae = new NoViableAltException("", 30, 0, input);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(30); }
			switch (alt30)
			{
			case 1:
				DebugEnterAlt(1);
				// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:540:8: identifier
				{
				DebugLocation(540, 8);
				PushFollow(Follow._identifier_in_type1921);
				identifier54=identifier();
				PopFollow();

				DebugLocation(540, 19);
				 type = new RefType(identifier54); 

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:541:8: INTEGER
				{
				DebugLocation(541, 8);
				INTEGER55=(IToken)Match(input,INTEGER,Follow._INTEGER_in_type1932); 
				DebugLocation(541, 16);
				 type = new PrimitiveType(INTEGER55); 

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:542:8: REAL
				{
				DebugLocation(542, 8);
				REAL56=(IToken)Match(input,REAL,Follow._REAL_in_type1943); 
				DebugLocation(542, 13);
				 type = new PrimitiveType(REAL56); 

				}
				break;

			}
		}

			catch (RecognitionException e)
			{
		        	throw e;
		    	}

		finally
		{
			TraceOut("type", 27);
			LeaveRule("type", 27);
			LeaveRule_type();
		}
		DebugLocation(543, 5);
		} finally { DebugExitRule(GrammarFileName, "type"); }
		return type;

	}