You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when using the (slightly altered for swift) grammar from the doc
grammar DynScope;
prog: block ;
block
/* List of symbols defined within this block */
locals [
symbols: [String]
]
: '{' decl* stat+ '}'
// print out all symbols found in block
// $block::symbols evaluates to a List as defined in scope
{print("symbols=\($symbols)");}
;
/** Match a declaration and add identifier name to list of symbols */
decl: 'int' ID {$block::symbols.append($ID.text);} ';' ;
/** Match an assignment then test list of symbols to verify
* that it contains the variable on the left side of the assignment.
* Method contains() is List.contains() because $block::symbols
* is a List.
*/
stat: ID '=' INT ';'
{
if ( !$block::symbols.contains($ID.text) ) {
print("undefined variable: "+$ID.text);
}
}
| block
;
ID : [a-z]+ ;
INT : [0-9]+ ;
WS : [ \t\r\n]+ -> skip ;
the generated code is: (BlockContext)getInvokingContext(1)).symbols.append((_localctx.castdown(DeclContext.self)._ID != nil ? _localctx.castdown(DeclContext.self)._ID!.getText()! : ""));
which uses an invalid c-style cast.
it should generate something like: (getInvokingContext(1) as! BlockContext).symbols.append((_localctx.castdown(DeclContext.self)._ID != nil ? _localctx.castdown(DeclContext.self)._ID!.getText()! : ""));
The text was updated successfully, but these errors were encountered:
when using the (slightly altered for swift) grammar from the doc
the generated code is:
(BlockContext)getInvokingContext(1)).symbols.append((_localctx.castdown(DeclContext.self)._ID != nil ? _localctx.castdown(DeclContext.self)._ID!.getText()! : ""));
which uses an invalid c-style cast.
it should generate something like:
(getInvokingContext(1) as! BlockContext).symbols.append((_localctx.castdown(DeclContext.self)._ID != nil ? _localctx.castdown(DeclContext.self)._ID!.getText()! : ""));
The text was updated successfully, but these errors were encountered: