vbnet.atg
来自「全功能c#编译器」· ATG 代码 · 共 2,539 行 · 第 1/5 页
ATG
2,539 行
.) =
"Exit" (. ExitType exitType = ExitType.None; .)
(
"Sub" (. exitType = ExitType.Sub; .)
|
"Function" (. exitType = ExitType.Function; .)
|
"Property" (. exitType = ExitType.Property; .)
|
"Do" (. exitType = ExitType.Do; .)
|
"For" (. exitType = ExitType.For; .)
|
"Try" (. exitType = ExitType.Try; .)
|
"While" (. exitType = ExitType.While; .)
|
"Select" (. exitType = ExitType.Select; .)
)
(. statement = new ExitStatement(exitType); .)
| TryStatement<out statement>
| /* 10.10.1.3 */
"Throw" [ Expr<out expr> ] (. statement = new ThrowStatement(expr); .)
| /* 10.11 */
"Return" [ Expr<out expr> ] (. statement = new ReturnStatement(expr); .)
| /* 10.4 */
"SyncLock" Expr<out expr> EndOfStmt Block<out embeddedStatement>
"End" "SyncLock" (. statement = new LockStatement(expr, embeddedStatement); .)
| /* 10.5.1 */
"RaiseEvent" Identifier (. name = t.val; .)
[ "(" [ ArgumentList<out p> ] ")" ]
(. statement = new RaiseEventStatement(name, p); .)
| /* 10.3 */
WithStatement<out statement>
| /* 10.5.2 */
"AddHandler" (. Expression handlerExpr = null; .)
Expr<out expr> "," Expr<out handlerExpr>
(.
statement = new AddHandlerStatement(expr, handlerExpr);
.)
| /* 10.5.2 */
"RemoveHandler" (. Expression handlerExpr = null; .)
Expr<out expr> "," Expr<out handlerExpr>
(.
statement = new RemoveHandlerStatement(expr, handlerExpr);
.)
| /* 10.9.1 */
"While" Expr<out expr> EndOfStmt
Block<out embeddedStatement> "End" "While"
(.
statement = new WhileStatement(expr, embeddedStatement);
.)
| /* 10.9.1 */
"Do"
(.
ConditionType conditionType = ConditionType.None;
.)
(
WhileOrUntil<out conditionType> Expr<out expr> EndOfStmt
Block<out embeddedStatement>
"Loop"
(.
statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.Start);
.)
|
EndOfStmt
Block<out embeddedStatement>
"Loop" [WhileOrUntil<out conditionType> Expr<out expr>]
(.
statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End);
.)
)
| "For"
(.
Expression group = null;
LoopControlVariableExpression loopControlExpr = null;
.)
(
/* 10.9.3 */
"Each" LoopControlVariable<out loopControlExpr>
"In" Expr<out group> EndOfStmt
Block<out embeddedStatement>
"Next" [ Expr<out expr> ]
(.
statement = new ForeachStatement(loopControlExpr, group, embeddedStatement, expr);
.)
| /* 10.9.2 */
(.
Expression start = null;
Expression end = null;
Expression step = null;
Expression nextExpr = null;
ArrayList nextExpressions = null;
.)
LoopControlVariable<out loopControlExpr>
"=" Expr<out start> "To" Expr<out end> [ "Step" Expr<out step> ]
EndOfStmt Block<out embeddedStatement>
"Next"
[
Expr<out nextExpr> (. nextExpressions = new ArrayList(); nextExpressions.Add(nextExpr); .)
{ "," Expr<out nextExpr> (. nextExpressions.Add(nextExpr); .) }
]
(.
statement = new ForStatement(loopControlExpr, start, end, step, embeddedStatement, nextExpressions);
.)
)
| /* 10.10.2.1 */
"Error" Expr<out expr> (. statement = new ErrorStatement(expr); .)
| /* 10.12.1 */
"ReDim" (. ReDimClause clause = null; .) [ "Preserve" ]
ReDimClause<out clause>
(.
ArrayList clauses = new ArrayList();
clauses.Add(clause);
ReDimStatement reDimStatement = new ReDimStatement(clauses);
.)
{ "," ReDimClause<out clause> (. clauses.Add(clause); .) }
| /* 10.12.2 */
"Erase"
Expr<out expr>
(.
ArrayList arrays = new ArrayList();
arrays.Add(expr);
EraseStatement eraseStatement = new EraseStatement(arrays);
.)
{ "," Expr<out expr> (. arrays.Add(expr); .) }
(. statement = eraseStatement; .)
| /* 10.11 */
"Stop" (. statement = new StopStatement(); .)
| /* 10.8.1 */
"If" Expr<out expr> [ "Then" ]
(
IF (IsEndStmtAhead()) "End" (. statement = new IfStatement(expr, new EndStatement()); .)
|
/* multiline if statement */
EndOfStmt Block<out embeddedStatement>
(.
ArrayList elseIfSections = new ArrayList();
IfStatement ifStatement = new IfStatement(expr, embeddedStatement);
.)
{
(
IF(IsElseIf()) "Else" "If"
| "ElseIf"
)
(. Expression condition = null; Statement block = null; .)
Expr<out condition> [ "Then"] EndOfStmt
Block<out block>
(.
ElseIfSection elseIfSection = new ElseIfSection(condition, block);
elseIfSections.Add(elseIfSection);
.)
}
[
"Else" EndOfStmt
Block<out embeddedStatement>
(.
ifStatement.EmbeddedElseStatement = embeddedStatement;
.)
] "End" "If"
(.
ifStatement.ElseIfStatements = elseIfSections;
statement = ifStatement;
.)
| /* singleline if statement */
EmbeddedStatement<out embeddedStatement>
(.
SimpleIfStatement ifStatement = new SimpleIfStatement(expr);
ArrayList statements = new ArrayList();
statements.Add(embeddedStatement);
ifStatement.Statements = statements;
.)
{ ":" EmbeddedStatement<out embeddedStatement> (. statements.Add(embeddedStatement); .) }
[
"Else" [ EmbeddedStatement<out embeddedStatement> ]
(.
ArrayList elseStatements = new ArrayList();
elseStatements.Add(embeddedStatement);
ifStatement.ElseStatements = elseStatements;
.)
{
":" EmbeddedStatement<out embeddedStatement>
(. elseStatements.Add(embeddedStatement); .)
}
]
(. statement = ifStatement; .)
)
| /* 10.8.2 */
"Select" [ "Case" ] Expr<out expr> EndOfStmt
(.
ArrayList selectSections = new ArrayList();
Statement block = null;
.)
{
(. ArrayList caseClauses = null; .)
"Case" CaseClauses<out caseClauses> [ IF(IsNotStatementSeparator()) ":" ] EndOfStmt
(.
SelectSection selectSection = new SelectSection();
selectSection.CaseClauses = caseClauses;
compilationUnit.BlockStart(selectSection);
.)
Block<out block>
(.
selectSection.EmbeddedStatement = block;
compilationUnit.BlockEnd();
selectSections.Add(selectSection);
.)
}
(. statement = new SelectStatement(expr, selectSections); .)
"End" "Select"
| (. OnErrorStatement onErrorStatement = null; .)
OnErrorStatement<out onErrorStatement> (. statement = onErrorStatement; .)
| (. GoToStatement goToStatement = null; .)
GoToStatement<out goToStatement> (. statement = goToStatement; .)
| (. ResumeStatement resumeStatement = null; .)
ResumeStatement<out resumeStatement> (. statement = resumeStatement; .)
|/* Statement expression (invocation and assignment) 10.6.1, 10.6.2, 10.6.3 */
(.
Expression val = null;
AssignmentOperatorType op;
bool mustBeAssignment = la.kind == Tokens.Plus || la.kind == Tokens.Minus ||
la.kind == Tokens.Not || la.kind == Tokens.Times;
.)
UnaryExpr<out expr>
(
AssignmentOperator<out op> Expr<out val> (. expr = new AssignmentExpression(expr, op, val); .)
| (. if (mustBeAssignment) Error("error in assignment."); .)
)
(.
// a field reference expression that stands alone is a
// invocation expression without parantheses and arguments
if(expr is FieldReferenceOrInvocationExpression) {
expr = new InvocationExpression(expr, new ArrayList());
}
statement = new StatementExpression(expr);
.)
| "Call" UnaryExpr<out expr> (. statement = new StatementExpression(expr); .)
.
/* 10.9.2 */
LoopControlVariable<out LoopControlVariableExpression loopExpr>
(.
loopExpr = null;
Expression expr = null;
TypeReference type = null;
ArrayList arrayModifiers = null;
string name;
.) =
Qualident<out name>
[ IF(IsDims()) ArrayTypeModifiers<out arrayModifiers> ]
[ "As" TypeName<out type> (. if (name.IndexOf('.') > 0) { Error("No type def for 'for each' member indexer allowed."); } .) ]
(.
if(type != null) {
if(type.RankSpecifier != null && arrayModifiers != null) {
Error("array rank only allowed one time");
} else {
type.RankSpecifier = arrayModifiers;
}
} else {
type = new TypeReference("Integer", arrayModifiers);
}
loopExpr = new LoopControlVariableExpression(name, type);
.)
|
Expr<out expr>
(. loopExpr = new LoopControlVariableExpression(expr); .)
.
/* 10.2.2 */
OnErrorStatement<out OnErrorStatement stmt>
(.
stmt = null;
GotoStatement goToStatement = null;
.)
=
"On" "Error"
(
IF(IsNegativeLabelName())"GoTo" "-" LiteralInteger
(.
long intLabel = Int64.Parse(t.val);
if(intLabel != 1) {
Error("invalid label in on error statement.");
}
stmt = new OnErrorStatement(new GotoStatement((intLabel * -1).ToString()));
.)
| GotoStatement<out goToStatement>
(.
string val = goToStatement.LabelName;
// if value is numeric, make sure that is 0
try {
long intLabel = Int64.Parse(val);
if(intLabel != 0) {
Error("invalid label in on error statement.");
}
} catch {
}
stmt = new OnErrorStatement(goToStatement);
.)
| "Resume" "Next"
(.
stmt = new OnErrorStatement(new ResumeStatement(true));
.)
)
.
/* 10.11 */
GoToStatement<out ICSharpCode.CsVbRefactory.Parser.AST.GotoStatement goToStatement>
(.
string label = String.Empty;
.)
=
"GoTo" LabelName<out label>
(.
goToStatement = new ICSharpCode.CsVbRefactory.Parser.AST.GotoStatement(label);
.)
.
/* 10.1 */
LabelName<out string name>
(.
name = String.Empty;
.) =
Identifier (. name = t.val; .)
| LiteralInteger (. name = t.val; .)
.
/* 12.12.1 */
ReDimClause<out ReDimClause clause>
(.
Expression initializer = null;
Expression arrayInitializer = null;
string name = String.Empty;
.) =
Qualident<out name>
(.
clause = new ReDimClause(name);
.)
"(" Expr<out initializer>
(.
clause.Initializers = new ArrayList();
clause.Initializers.Add(initializer);
.)
{ "," Expr<out initializer> (. clause.Initializers.Add(initializer); .) }
")"
[ ArrayInitializer<out arrayInitializer> ]
.
/* 10.10.2.3 */
ResumeStatement<out ResumeStatement resumeStatement>
(.
resumeStatement = null;
string label = String.Empty;
.) =
IF(IsResumeNext())
"Resume" "Next" (. resumeStatement = new ResumeStatement(true); .)
| "Resume" [ LabelName<out label> ] (. resumeStatement = new ResumeStatement(label); .)
.
/* 18.8.2 */
CaseClauses<out ArrayList caseClauses>
(.
caseClauses = null;
CaseClause caseClause = null;
.) =
CaseClause<out caseClause>
(.
caseClauses = new ArrayList();
caseClauses.Add(caseClause);
.)
{ "," CaseClause<out caseClause> (. caseClauses.Add(caseClause); .) }
.
/* 19.8.2 */
CaseClause<out CaseLabel caseClause>
(.
Expression expr = null;
Expression sexpr = null;
BinaryOperatorType op = BinaryOperatorType.None;
caseClause = null;
.) =
"Else"
(. caseClause = new CaseLabel(); .)
|
[ "Is" ]
(
"<" (. op = BinaryOperatorType.LessThan; .)
| ">" (. op = BinaryOperatorType.GreaterThan; .)
| "<=" (. op = BinaryOperatorType.LessThanOrEqual; .)
| ">=" (. op = BinaryOperatorType.GreaterThanOrEqual; .)
| "=" (. op = BinaryOperatorType.Equality; .)
| "<>" (. op = BinaryOperatorType.InEquality; .)
)
Expr<out expr>
(.
caseClause = new CaseLabel(op, expr);
.)
| Expr<out expr> [ "To" Expr<out sexpr> ]
(.
caseClause = new CaseLabel(expr, sexpr);
.)
.
/* 10.9.1 */
WhileOrUntil<out ConditionType conditionType>
(. conditionType = ConditionType.None; .) =
"While" (. conditionType = ConditionType.While; .)
| "Until" (. conditionType = ConditionType.Until; .)
.
/* 10.3 */
WithStatement<out Statement withStatement>
(.
Statement blockStmt = null;
Expression expr = null;
.) =
"With" (. Point start = t.Location; .)
Expr<out expr> EndOfStmt
(.
withStatement = new WithStatement(expr);
withStatement.StartLocation = start;
withStatements.Push(withStatement);
.)
Block<out blockStmt>
(.
((WithStatement)withStatement).Body = (BlockStatement)blockStmt;
withStatements.Pop();
.)
"End" "With"
(. withStatement.EndLocation = t.Location; .)
.
/* 10.10.1 */
TryStatement<out Statement tryStatement>
(.
Statement blockStmt = null, finallyStmt = null;
ArrayList catchClauses = null;
.) =
"Try" EndOfStmt
Block<out blockStmt>
(
CatchClauses<out catchClauses>
[ "Finally" EndOfStmt Block<out finallyStmt> ]
| "Finally" EndOfStmt Block<out finallyStmt>
)
"End" "Try"
(.
tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
.)
.
/* 10.10.1.2 */
CatchClauses<out ArrayList catchClauses>
(.
catchClauses = new ArrayList();
TypeReference type = null;
Statement blockStmt = null;
Expression expr = null;
string name = String.Empty;
.) =
{
"Catch"
[ Identifier (. name = t.val; .) ["As" TypeName<out type>] ]
[ "When" Expr<out expr> ]
EndOfStmt
Block<out blockStmt>
(. catchClauses.Add(new CatchClause(type, name, blockStmt, expr)); .)
}
.
/* 4.7 */
Qualident<out string qualident>
(. string name = String.Empty; .) =
Identifier (. StringBuilder qualidentBuilder = new StringBuilder(t.val); .)
{
"." IdentifierOrKeyword<out name> (. qualidentBuilder.Append('.');
qualidentBuilder.Append(name);
.)
}
(. qualident = qualidentBuilder.ToString(); .)
.
/* This production handles pseudo keywords that are needed in the grammar */
Identifier =
ident
| "Text"
| "Binary"
| "Compare"
.
/* 2.2 */
IdentifierOrKeyword<out string name>
(.
name = String.Empty;
.) =
Identifier (. name = t.val; .)
| "AddHandler" (. name = t.val; .)
| "AddressOf" (. name = t.val; .)
| "Alias" (. name = t.val; .)
| "And" (. name = t.val; .)
| "AndAlso" (. name = t.val; .)
| "Ansi" (. name = t.val; .)
| "As" (. name = t.val; .)
| "Assembly" (. name = t.val; .)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?