本文整理汇总了C#中ErrorHandler.getErrors方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorHandler.getErrors方法的具体用法?C# ErrorHandler.getErrors怎么用?C# ErrorHandler.getErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler.getErrors方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ForgettingEndStatement
public void ForgettingEndStatement()
{
Tokenizer t = new Tokenizer(s_errorHandler, true);
ErrorHandler e = new ErrorHandler();
Parser p = new Parser(t.process(File.OpenText("code68.txt")), e);
p.process();
ScopeBuilder scopeBuilder = new ScopeBuilder(p.getAST(), e);
scopeBuilder.process();
e.printErrorsToConsole();
Assert.AreEqual(1, e.getErrors().Count);
}
示例2: ParseSomeExpressionsWithFunctions
public void ParseSomeExpressionsWithFunctions()
{
Tokenizer tokenizer = new Tokenizer(s_errorHandler, true);
List<Token> tokens = tokenizer.process(File.OpenText("code15.txt"));
ErrorHandler errorHandler = new ErrorHandler();
Parser parser = new Parser(tokens, errorHandler);
parser.process();
//Console.WriteLine("Tree: " + parser.getAST().getTreeAsString());
Assert.AreEqual(0, errorHandler.getErrors().Count);
}
示例3: ParseSimpleExpression
public void ParseSimpleExpression()
{
List<Token> tokens = new List<Token>();
tokens.Add(new Token(Token.TokenType.NAME, "a"));
tokens.Add(new Token(Token.TokenType.OPERATOR, "+"));
tokens.Add(new Token(Token.TokenType.NAME, "b"));
ErrorHandler errorHandler = new ErrorHandler();
Parser parser = new Parser(tokens, errorHandler);
parser.process();
Assert.AreEqual(0, errorHandler.getErrors().Count);
}
示例4: ParseSingleName
public void ParseSingleName()
{
List<Token> tokens = new List<Token>();
tokens.Add(new Token(Token.TokenType.NAME, "erik"));
ErrorHandler errorHandler = new ErrorHandler();
Parser parser = new Parser(tokens, errorHandler);
parser.process();
Assert.AreEqual(0, errorHandler.getErrors().Count);
}
示例5: ParseLongerExpression
public void ParseLongerExpression()
{
List<Token> tokens = new List<Token>();
tokens.Add(new Token(Token.TokenType.NUMBER, "2"));
tokens.Add(new Token(Token.TokenType.OPERATOR, "*"));
tokens.Add(new Token(Token.TokenType.NUMBER, "3"));
tokens.Add(new Token(Token.TokenType.OPERATOR, "+"));
tokens.Add(new Token(Token.TokenType.NUMBER, "4"));
tokens.Add(new Token(Token.TokenType.OPERATOR, "*"));
tokens.Add(new Token(Token.TokenType.NUMBER, "5"));
ErrorHandler errorHandler = new ErrorHandler();
Parser parser = new Parser(tokens, errorHandler);
parser.process();
Assert.AreEqual(0, errorHandler.getErrors().Count);
}
示例6: ParseIfElseBlock
public void ParseIfElseBlock()
{
List<Token> tokens = new List<Token>();
tokens.Add(new Token(Token.TokenType.IF, "if"));
tokens.Add(new Token(Token.TokenType.PARANTHESIS_LEFT, "("));
tokens.Add(new Token(Token.TokenType.NAME, "m_hasGotCandy"));
tokens.Add(new Token(Token.TokenType.PARANTHESIS_RIGHT, ")"));
tokens.Add(new Token(Token.TokenType.NEW_LINE, "\n"));
tokens.Add(new Token(Token.TokenType.NAME, "boringFunction"));
tokens.Add(new Token(Token.TokenType.PARANTHESIS_LEFT, "("));
tokens.Add(new Token(Token.TokenType.PARANTHESIS_RIGHT, ")"));
tokens.Add(new Token(Token.TokenType.NEW_LINE, "\n"));
tokens.Add(new Token(Token.TokenType.BLOCK_END, "end"));
tokens.Add(new Token(Token.TokenType.ELSE, "else"));
tokens.Add(new Token(Token.TokenType.NEW_LINE, "\n"));
tokens.Add(new Token(Token.TokenType.BLOCK_END, "end"));
ErrorHandler errorHandler = new ErrorHandler();
Parser parser = new Parser(tokens, errorHandler);
parser.process();
Assert.AreEqual(0, errorHandler.getErrors().Count);
}
示例7: ParseFunctionDeclaration
public void ParseFunctionDeclaration()
{
List<Token> tokens = new List<Token>();
tokens.Add(new Token(Token.TokenType.BUILT_IN_TYPE_NAME, "float"));
tokens.Add(new Token(Token.TokenType.NAME, "foo"));
tokens.Add(new Token(Token.TokenType.PARANTHESIS_LEFT, "("));
tokens.Add(new Token(Token.TokenType.PARANTHESIS_RIGHT, ")"));
tokens.Add(new Token(Token.TokenType.BLOCK_END, "end"));
ErrorHandler errorHandler = new ErrorHandler();
Parser parser = new Parser(tokens, errorHandler);
parser.process();
Console.WriteLine("Tree: " + parser.getAST().getTreeAsString());
errorHandler.printErrorsToConsole();
Assert.AreEqual(0, errorHandler.getErrors().Count);
}
示例8: ParseFunctionCallWithParameters
public void ParseFunctionCallWithParameters()
{
List<Token> tokens = new List<Token>();
tokens.Add(new Token(Token.TokenType.NAME, "foo"));
tokens.Add(new Token(Token.TokenType.PARANTHESIS_LEFT, "("));
tokens.Add(new Token(Token.TokenType.NAME, "a"));
tokens.Add(new Token(Token.TokenType.COMMA, ","));
tokens.Add(new Token(Token.TokenType.NAME, "bar"));
tokens.Add(new Token(Token.TokenType.PARANTHESIS_LEFT, "("));
tokens.Add(new Token(Token.TokenType.PARANTHESIS_RIGHT, ")"));
tokens.Add(new Token(Token.TokenType.COMMA, ","));
tokens.Add(new Token(Token.TokenType.NUMBER, "400"));
tokens.Add(new Token(Token.TokenType.PARANTHESIS_RIGHT, ")"));
ErrorHandler errorHandler = new ErrorHandler();
Parser parser = new Parser(tokens, errorHandler);
parser.process();
Assert.AreEqual(0, errorHandler.getErrors().Count);
}
示例9: ParseAssignment
public void ParseAssignment()
{
List<Token> tokens = new List<Token>();
tokens.Add(new Token(Token.TokenType.NAME, "variable"));
tokens.Add(new Token(Token.TokenType.ASSIGNMENT, "="));
tokens.Add(new Token(Token.TokenType.NUMBER, "42"));
ErrorHandler errorHandler = new ErrorHandler();
Parser parser = new Parser(tokens, errorHandler);
parser.process();
Assert.AreEqual(0, errorHandler.getErrors().Count);
}