Пример #1
0
 private static AstNode ParseGiven(TokenStream stream)
 {
     GivenStatement switchStmt = new GivenStatement (stream.Location);
     stream.Expect (TokenClass.Keyword, "given");
     stream.Expect (TokenClass.OpenParan);
     switchStmt.Add (ParseExpression (stream));
     stream.Expect (TokenClass.CloseParan);
     stream.Expect (TokenClass.OpenBrace);
     AstNode defaultBlock = new AstRoot (stream.Location);
     AstRoot caseStatements = new AstRoot (stream.Location);
     while (!stream.EndOfStream && !stream.Match (TokenClass.CloseBrace)) {
         caseStatements.Add (ParseWhen (stream));
         if (stream.Accept (TokenClass.Keyword, "default")) {
             defaultBlock = ParseStatement (stream);
         }
     }
     switchStmt.Add (caseStatements);
     switchStmt.Add (defaultBlock);
     stream.Expect (TokenClass.CloseBrace);
     return switchStmt;
 }
Пример #2
0
		public override void Accept (GivenStatement switchStmt)
		{
			foreach (AstNode node in switchStmt.WhenStatements.Children) {
				WhenStatement caseStmt = node as WhenStatement;
				caseStmt.Values.Visit (this);
				caseStmt.Body.Visit (this);
			}
			switchStmt.GivenValue.Visit (this);
			methodBuilder.EmitInstruction (switchStmt.Location, Opcode.SwitchLookup, switchStmt.WhenStatements.Children.Count);
			IodineLabel endLabel = methodBuilder.CreateLabel ();
			methodBuilder.EmitInstruction (switchStmt.Location, Opcode.JumpIfTrue, endLabel);
			switchStmt.DefaultStatement.Visit (this);
			methodBuilder.MarkLabelPosition (endLabel);
		}
Пример #3
0
 public void Accept(GivenStatement switchStmt)
 {
 }
Пример #4
0
		public override void Accept (GivenStatement switchStmt)
		{
			errorLog.AddError (ErrorType.ParserError, switchStmt.Location,
				"statement can not exist inside pattern!");
		}
Пример #5
0
 public void Accept(GivenStatement switchStmt)
 {
     switchStmt.VisitChildren (this);
 }
Пример #6
0
 public void Accept(GivenStatement switchStmt)
 {
     errorLog.AddError (ErrorType.ParserError, switchStmt.Location,
         "Statement not allowed outside function body!");
 }