mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Wrap qualified identifier in a sub-tree
By wrapping in a subtree we can use qualified_identifier.text to extract all the input that was matched by that rule, otherwise 'text' only matches the first node in a list. Took me ages to find that :( Send comments to hidden channel, hiopefully we can then retrieve them later.
This commit is contained in:
parent
7f6591b0d1
commit
b62e86c401
@ -13,6 +13,7 @@ options {
|
||||
ASTLabelType=CommonTree;
|
||||
language=CSharp2;
|
||||
superClass='RusticiSoftware.Translator.CSharp.CommonWalker';
|
||||
output=AST;
|
||||
//backtrack=true;
|
||||
}
|
||||
|
||||
@ -57,7 +58,7 @@ scope UseScope;
|
||||
;
|
||||
|
||||
namespace_declaration:
|
||||
'namespace' qualified_identifier namespace_block ';'? ;
|
||||
'namespace' qi=qualified_identifier { Debug($qi.text); } namespace_block ';'? ;
|
||||
namespace_block:
|
||||
'{' namespace_body '}' ;
|
||||
namespace_body:
|
||||
@ -114,7 +115,7 @@ namespace_or_type_name:
|
||||
type_or_generic ('::' type_or_generic)? ('.' type_or_generic)* ;
|
||||
type_or_generic:
|
||||
(identifier '<') => identifier generic_argument_list
|
||||
| identifier
|
||||
| identifier
|
||||
;
|
||||
|
||||
generic_argument_list:
|
||||
@ -129,8 +130,10 @@ type:
|
||||
| 'void' '*'+
|
||||
;
|
||||
|
||||
qualified_identifier:
|
||||
identifier ('.' identifier)* ;
|
||||
qualified_identifier
|
||||
@after{ Console.WriteLine("qualified_identifier(): " + $qualified_identifier.text); }
|
||||
:
|
||||
^(QID identifier+) ;
|
||||
|
||||
namespace_name
|
||||
: namespace_or_type_name ;
|
||||
@ -162,6 +165,12 @@ predefined_type:
|
||||
'bool' | 'byte' | 'char' | 'decimal' | 'double' | 'float' | 'int' | 'long' | 'object' | 'sbyte'
|
||||
| 'short' | 'string' | 'uint' | 'ulong' | 'ushort' ;
|
||||
|
||||
identifier:
|
||||
IDENTIFIER { Debug($IDENTIFIER.Text); } ;
|
||||
identifier
|
||||
@after{ Console.WriteLine("identifier(): " + $identifier.text); }
|
||||
:
|
||||
IDENTIFIER
|
||||
| 'add' | 'alias' | 'assembly' | 'module' | 'field' | 'method' | 'param' | 'property' | 'type'
|
||||
| 'yield' | 'from' | 'into' | 'join' | 'on' | 'where' | 'orderby' | 'group' | 'by' | 'ascending' | 'descending' | 'equals' | 'select' | 'pragma' | 'let' | 'remove' | 'set' | 'var' | '__arglist' | 'dynamic'
|
||||
;
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ options {
|
||||
|
||||
|
||||
tokens {
|
||||
BLOCK;
|
||||
QID;
|
||||
}
|
||||
|
||||
@namespace { RusticiSoftware.Translator.CSharp }
|
||||
@ -43,7 +43,7 @@ compilation_unit:
|
||||
namespace_declaration:
|
||||
'namespace' qualified_identifier namespace_block ';'? ;
|
||||
namespace_block:
|
||||
'{' namespace_body[false] '}' -> ^(BLOCK namespace_body) ;
|
||||
'{' namespace_body[false] '}' ;
|
||||
namespace_body[bool bGlobal]:
|
||||
extern_alias_directives? using_directives? global_attributes? namespace_member_declarations? ;
|
||||
extern_alias_directives:
|
||||
@ -75,7 +75,8 @@ type_declaration:
|
||||
| delegate_declaration ;
|
||||
// Identifiers
|
||||
qualified_identifier:
|
||||
identifier ('.' identifier)* ;
|
||||
i+=identifier ('.' i+=identifier)*
|
||||
-> ^(QID $i+) ;
|
||||
namespace_name
|
||||
: namespace_or_type_name ;
|
||||
|
||||
@ -1084,15 +1085,15 @@ TS:
|
||||
{ Skip(); } ;
|
||||
DOC_LINE_COMMENT
|
||||
: ('///' ~('\n'|'\r')* ('\r' | '\n')+)
|
||||
{ Skip(); } ;
|
||||
{$channel=Hidden;} ;
|
||||
LINE_COMMENT
|
||||
: ('//' ~('\n'|'\r')* ('\r' | '\n')+)
|
||||
{ Skip(); } ;
|
||||
{$channel=Hidden;} ;
|
||||
COMMENT:
|
||||
'/*'
|
||||
(options {greedy=false;} : . )*
|
||||
'*/'
|
||||
{ Skip(); } ;
|
||||
{$channel=Hidden;} ;
|
||||
STRINGLITERAL
|
||||
:
|
||||
'"' (EscapeSequence | ~('"' | '\\'))* '"' ;
|
||||
|
Loading…
x
Reference in New Issue
Block a user