mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Refresh cs2j parser from AntlrCSharp repository
This commit is contained in:
parent
11663b51fd
commit
4c9ef39275
@ -231,7 +231,7 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
w.Close();
|
w.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// keving: comment out for now doFile(new FileInfo(args[i]), ".cs", translateFile, exclude); // parse it
|
// keving: comment out for now doFile(new FileInfo(args[i]), ".cs", translateFile, exclude); // parse it
|
||||||
if (enumXmlWriter != null)
|
if (enumXmlWriter != null)
|
||||||
{
|
{
|
||||||
enumXmlWriter.WriteEndElement();
|
enumXmlWriter.WriteEndElement();
|
||||||
@ -358,17 +358,18 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static void DumpNodes(CommonTreeNodeStream nodes)
|
private static void DumpNodes(CommonTreeNodeStream nodes)
|
||||||
{
|
{
|
||||||
// Dump out nodes if -n on command line
|
|
||||||
// if (Util.Args.IsFlagSet("-n"))
|
|
||||||
// {
|
|
||||||
Console.ForegroundColor = ConsoleColor.Magenta;
|
Console.ForegroundColor = ConsoleColor.Magenta;
|
||||||
Console.WriteLine("Nodes");
|
Console.WriteLine("Nodes");
|
||||||
int spaces = 0;
|
int spaces = 0;
|
||||||
string str_spaces = " ";
|
string str_spaces = " ";
|
||||||
object o_prev = string.Empty;
|
object o_prev = string.Empty;
|
||||||
for (int n = 0; n < nodes.Count; ++n)
|
//for (int n = 0; n < nodes.Count; ++n)
|
||||||
|
object o = nodes.NextElement();
|
||||||
|
while (!nodes.IsEndOfFile(o))
|
||||||
{
|
{
|
||||||
object o = nodes.Get(n);
|
//object o = nodes.Get(n);
|
||||||
|
//object o = nodes[n];
|
||||||
|
|
||||||
if (o.ToString() == "DOWN")
|
if (o.ToString() == "DOWN")
|
||||||
{
|
{
|
||||||
spaces += 2;
|
spaces += 2;
|
||||||
@ -385,13 +386,13 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
Console.Write(" {0}", o_prev.ToString());
|
Console.Write(" {0}", o_prev.ToString());
|
||||||
|
|
||||||
o_prev = o;
|
o_prev = o;
|
||||||
|
o = nodes.NextElement();
|
||||||
}
|
}
|
||||||
if (o_prev.ToString() != "UP" && o_prev.ToString() != "DOWN")
|
if (o_prev.ToString() != "UP" && o_prev.ToString() != "DOWN")
|
||||||
Console.WriteLine(" {0}", o_prev.ToString());
|
Console.WriteLine(" {0}", o_prev.ToString());
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here's where we do the real work...
|
// Here's where we do the real work...
|
||||||
public static void addNetTranslation(string fullName, Stream s)
|
public static void addNetTranslation(string fullName, Stream s)
|
||||||
{
|
{
|
||||||
@ -406,8 +407,8 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
if (t != null)
|
if (t != null)
|
||||||
{
|
{
|
||||||
// A prescan of all files to build an environment mapping qualified name to typereptemplate
|
// A prescan of all files to build an environment mapping qualified name to typereptemplate
|
||||||
// CSharpEnvBuilder envBuilder = new CSharpEnvBuilder();
|
// CSharpEnvBuilder envBuilder = new CSharpEnvBuilder();
|
||||||
// envBuilder.compilationUnit(t, null, appEnv);
|
// envBuilder.compilationUnit(t, null, appEnv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
// PreProcessor.cs
|
// PreProcessor.cs
|
||||||
//
|
//
|
||||||
|
// Andrew Bradnan 2009-2010
|
||||||
|
// andrew.bradnan@gmail.com
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Antlr.Runtime;
|
using Antlr.Runtime;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Debug = System.Diagnostics.Debug;
|
|
||||||
|
|
||||||
namespace RusticiSoftware.Translator.CSharp
|
namespace Browse
|
||||||
{
|
{
|
||||||
/// <summary> PreProcessor
|
/// <summary> PreProcessor
|
||||||
/// The lexer preprocesses the CSharp code.
|
/// The lexer preprocesses the CSharp code.
|
||||||
@ -25,33 +25,14 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
Processing.Push(true);
|
Processing.Push(true);
|
||||||
|
|
||||||
// Grab what's defined from the command line
|
// Grab what's defined from the command line
|
||||||
//string[] args = Environment.GetCommandLineArgs();
|
string[] args = Environment.GetCommandLineArgs();
|
||||||
//for(int n = 0; n < args.Length; ++n)
|
for(int n = 0; n < args.Length; ++n)
|
||||||
//{
|
{
|
||||||
// if (args[n] == "-D")
|
if (args[n] == "-D")
|
||||||
// if ((n + 1) < args.Length)
|
if ((n + 1) < args.Length)
|
||||||
// MacroDefines.Add(args[n + 1], string.Empty);
|
MacroDefines.Add(args[n + 1], string.Empty);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PreProcessor(ICharStream input)
|
|
||||||
{
|
|
||||||
// By default we are preprocessing input
|
|
||||||
Processing.Push(true);
|
|
||||||
|
|
||||||
base.CharStream = input;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add a macro variable to the environment
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="define">Name of macro to define</param>
|
|
||||||
public void AddDefine(string define)
|
|
||||||
{
|
|
||||||
MacroDefines.Add(define, string.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void mTokens()
|
public override void mTokens()
|
||||||
{
|
{
|
||||||
base.mTokens();
|
base.mTokens();
|
||||||
@ -99,7 +80,8 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override String GetErrorMessage(RecognitionException e, String[] tokenNames)
|
public override String GetErrorMessage(RecognitionException e, String[] tokenNames)
|
||||||
{
|
{
|
||||||
IList stack = GetRuleInvocationStack(e, this.GetType().Name);
|
IList<string> stack = GetRuleInvocationStack(e, this.GetType().Name);
|
||||||
|
String msg = null;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.Append("\r\n");
|
sb.Append("\r\n");
|
||||||
foreach (object o in stack)
|
foreach (object o in stack)
|
||||||
|
@ -8,47 +8,56 @@
|
|||||||
|
|
||||||
grammar cs;
|
grammar cs;
|
||||||
|
|
||||||
|
|
||||||
options {
|
options {
|
||||||
backtrack=true;
|
backtrack=true;
|
||||||
memoize=true;
|
memoize=true;
|
||||||
output=AST;
|
output=AST;
|
||||||
language=CSharp2;
|
language=CSharp2;
|
||||||
}
|
}
|
||||||
|
|
||||||
tokens
|
tokens
|
||||||
{
|
{
|
||||||
|
ARGUMENTS;
|
||||||
ASSIGNMENT;
|
ASSIGNMENT;
|
||||||
BLOCK;
|
BLOCK;
|
||||||
CAST_EXPRESSION;
|
CAST_EXPRESSION;
|
||||||
CLASS_DECL;
|
CLASS_DECL;
|
||||||
|
CLASS_INHERITANCE;
|
||||||
DELEGATE_DECL;
|
DELEGATE_DECL;
|
||||||
ELSE;
|
ELSE;
|
||||||
|
EMPTY_BODY;
|
||||||
ENUM_DECL;
|
ENUM_DECL;
|
||||||
EXPRESSION;
|
EXPRESSION;
|
||||||
FIELD_DECL;
|
FIELD_DECL;
|
||||||
|
FIXED_PARAMETER;
|
||||||
|
ID;
|
||||||
IF;
|
IF;
|
||||||
INTERFACE_DECL;
|
INTERFACE_DECL;
|
||||||
INVOCATION_EXPRESSION;
|
INVOCATION_EXPRESSION;
|
||||||
|
LOCAL_VAR;
|
||||||
LOCAL_VARIABLE_DECLARATOR;
|
LOCAL_VARIABLE_DECLARATOR;
|
||||||
MEMBER_ACCESS;
|
MEMBER_ACCESS;
|
||||||
METHOD_DECL;
|
METHOD_DECL;
|
||||||
NAMESPACE_DECL;
|
NAMESPACE_DECL;
|
||||||
NAMESPACE_OR_TYPE_NAME;
|
NAMESPACE_OR_TYPE_NAME;
|
||||||
|
NON_ASSIGNMENT_EXPRESSION;
|
||||||
|
NSTN;
|
||||||
PREDEFINED_TYPE;
|
PREDEFINED_TYPE;
|
||||||
|
PRIMARY;
|
||||||
PROPERTY_DECLARATION;
|
PROPERTY_DECLARATION;
|
||||||
QID_PART;
|
QID_PART;
|
||||||
RETURN_TYPE;
|
TYPE;
|
||||||
|
TYPE_NAME;
|
||||||
UNARY_EXPRESSION;
|
UNARY_EXPRESSION;
|
||||||
USING_DIRECTIVE;
|
USING_DIRECTIVE;
|
||||||
|
VARIABLE_DECLARATOR;
|
||||||
|
|
||||||
TELEMENT;
|
TELEMENT;
|
||||||
TMEMBER;
|
TMEMBER;
|
||||||
TINVOCATION;
|
TINVOCATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@lexer::header {
|
@lexer::header {
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Debug = System.Diagnostics.Debug;
|
using Debug = System.Diagnostics.Debug;
|
||||||
}
|
}
|
||||||
@ -66,10 +75,7 @@ tokens
|
|||||||
|
|
||||||
@header
|
@header
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
@ -81,27 +87,11 @@ compilation_unit:
|
|||||||
// extern_alias_directives?
|
// extern_alias_directives?
|
||||||
using_directives?
|
using_directives?
|
||||||
global_attributes?
|
global_attributes?
|
||||||
namespace_declaration?
|
namespace_body? // specific namespace or in the global namespace
|
||||||
namespace_body
|
|
||||||
;
|
;
|
||||||
namespace_declaration:
|
namespace_declaration:
|
||||||
'namespace' qualified_identifier namespace_block ';'?
|
'namespace' qualified_identifier namespace_block ';'?
|
||||||
-> ^(NAMESPACE_DECL 'namespace' qualified_identifier namespace_block ';'?) ;
|
-> ^(NAMESPACE_DECL 'namespace' qualified_identifier namespace_block ';'?) ;
|
||||||
qualified_identifier:
|
|
||||||
identifier ('.' identifier)* ;
|
|
||||||
|
|
||||||
qid: // qualified_identifier v2
|
|
||||||
qid_start qid_part* ;
|
|
||||||
qid_start:
|
|
||||||
identifier ('::' identifier)? generic_argument_list?
|
|
||||||
| 'this'
|
|
||||||
| 'base'
|
|
||||||
| predefined_type
|
|
||||||
| literal ; // 0.ToString() is legal
|
|
||||||
qid_part:
|
|
||||||
access_operator identifier generic_argument_list?
|
|
||||||
-> ^(QID_PART access_operator identifier generic_argument_list?) ;
|
|
||||||
|
|
||||||
namespace_block:
|
namespace_block:
|
||||||
'{' namespace_body '}' ;
|
'{' namespace_body '}' ;
|
||||||
namespace_body:
|
namespace_body:
|
||||||
@ -134,14 +124,31 @@ type_declaration:
|
|||||||
qualified_alias_member:
|
qualified_alias_member:
|
||||||
identifier '::' identifier generic_argument_list? ;
|
identifier '::' identifier generic_argument_list? ;
|
||||||
|
|
||||||
|
// Identifiers
|
||||||
|
qualified_identifier:
|
||||||
|
identifier ('.' identifier)* ;
|
||||||
|
|
||||||
|
qid: // qualified_identifier v2
|
||||||
|
qid_start qid_part* ;
|
||||||
|
qid_start:
|
||||||
|
identifier ('::' identifier)? generic_argument_list?
|
||||||
|
| 'this'
|
||||||
|
| 'base'
|
||||||
|
| predefined_type
|
||||||
|
| literal ; // 0.ToString() is legal
|
||||||
|
qid_part:
|
||||||
|
access_operator identifier generic_argument_list?
|
||||||
|
-> ^(QID_PART access_operator identifier generic_argument_list?) ;
|
||||||
|
|
||||||
|
|
||||||
// B.2.1 Basic Concepts
|
// B.2.1 Basic Concepts
|
||||||
namespace_name
|
namespace_name
|
||||||
: namespace_or_type_name ;
|
: namespace_or_type_name ;
|
||||||
type_name:
|
type_name:
|
||||||
namespace_or_type_name ;
|
namespace_or_type_name -> ^(TYPE_NAME namespace_or_type_name) ;
|
||||||
namespace_or_type_name:
|
namespace_or_type_name:
|
||||||
id1 = identifier ga1 = generic_argument_list? ('::' id2 = identifier ga2 = generic_argument_list?)? ('.' id3 = identifier ga3 = generic_argument_list?)*
|
id1 = identifier ga1 = generic_argument_list? ('::' id2 = identifier ga2 = generic_argument_list?)? ('.' id3 += identifier ga3 += generic_argument_list?)*
|
||||||
-> ^(NAMESPACE_OR_TYPE_NAME $id1 $ga1? ('::' $id2 $ga2?)? ('.' $id3 $ga3?)* )
|
-> ^(NAMESPACE_OR_TYPE_NAME ^(NSTN $id1 $ga1?) ^(NSTN '::' $id2 $ga2?)? ^(NSTN $id3 $ga3?)*)
|
||||||
// | qualified_alias_member (the :: part)
|
// | qualified_alias_member (the :: part)
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -190,14 +197,15 @@ attribute_argument_expression:
|
|||||||
|
|
||||||
/* I'm going to ignore the mostly semantic bnf in the C Sharp spec and just do syntax */
|
/* I'm going to ignore the mostly semantic bnf in the C Sharp spec and just do syntax */
|
||||||
type:
|
type:
|
||||||
(type_name | predefined_type) rank_specifiers '*'*
|
(type_name | predefined_type) rank_specifiers '*'* ->
|
||||||
| type_name '*'+
|
^(TYPE type_name? predefined_type? rank_specifiers '*'*)
|
||||||
| type_name '?'
|
| type_name '*'+ -> ^(TYPE type_name '*'+)
|
||||||
| type_name
|
| type_name '?' -> ^(TYPE type_name '?')
|
||||||
| predefined_type '*'+
|
| type_name -> ^(TYPE type_name)
|
||||||
| predefined_type '?'
|
| predefined_type '*'+ -> ^(TYPE predefined_type '*'+)
|
||||||
| predefined_type
|
| predefined_type '?' -> ^(TYPE predefined_type '?')
|
||||||
| 'void' '*'+ ;
|
| predefined_type -> ^(TYPE predefined_type)
|
||||||
|
| 'void' '*'+ -> ^(TYPE 'void' '*'+) ;
|
||||||
non_nullable_type:
|
non_nullable_type:
|
||||||
(type_name | predefined_type) rank_specifiers '*'*
|
(type_name | predefined_type) rank_specifiers '*'*
|
||||||
| type_name '*'+
|
| type_name '*'+
|
||||||
@ -240,6 +248,13 @@ type_variable_name:
|
|||||||
expression:
|
expression:
|
||||||
non_assignment_expression -> ^(EXPRESSION non_assignment_expression)
|
non_assignment_expression -> ^(EXPRESSION non_assignment_expression)
|
||||||
| assignment -> ^(EXPRESSION assignment);
|
| assignment -> ^(EXPRESSION assignment);
|
||||||
|
non_assignment_expression:
|
||||||
|
conditional_expression
|
||||||
|
| lambda_expression
|
||||||
|
| query_expression ;
|
||||||
|
assignment:
|
||||||
|
unary_expression assignment_operator expression
|
||||||
|
-> ^(ASSIGNMENT unary_expression assignment_operator expression) ;
|
||||||
unary_expression:
|
unary_expression:
|
||||||
cast_expression // primary_expression... has parenthesized_expression
|
cast_expression // primary_expression... has parenthesized_expression
|
||||||
| '+' unary_expression
|
| '+' unary_expression
|
||||||
@ -252,6 +267,8 @@ unary_expression:
|
|||||||
| primary_or_array_creation_expression '++'? '--'? -> ^(UNARY_EXPRESSION primary_or_array_creation_expression '++'? '--'?)
|
| primary_or_array_creation_expression '++'? '--'? -> ^(UNARY_EXPRESSION primary_or_array_creation_expression '++'? '--'?)
|
||||||
| pointer_indirection_expression
|
| pointer_indirection_expression
|
||||||
| addressof_expression ;
|
| addressof_expression ;
|
||||||
|
assignment_operator:
|
||||||
|
'=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>' '>=' ;
|
||||||
pre_increment_expression:
|
pre_increment_expression:
|
||||||
'++' unary_expression ;
|
'++' unary_expression ;
|
||||||
pre_decrement_expression:
|
pre_decrement_expression:
|
||||||
@ -260,13 +277,6 @@ pointer_indirection_expression:
|
|||||||
'*' unary_expression ;
|
'*' unary_expression ;
|
||||||
addressof_expression:
|
addressof_expression:
|
||||||
'&' unary_expression ;
|
'&' unary_expression ;
|
||||||
non_assignment_expression:
|
|
||||||
conditional_expression
|
|
||||||
| lambda_expression
|
|
||||||
| query_expression;
|
|
||||||
assignment:
|
|
||||||
unary_expression assignment_operator expression
|
|
||||||
-> ^(ASSIGNMENT unary_expression assignment_operator expression) ;
|
|
||||||
variable_reference:
|
variable_reference:
|
||||||
expression ;
|
expression ;
|
||||||
|
|
||||||
@ -293,31 +303,8 @@ primary_or_array_creation_expression:
|
|||||||
primary_expression
|
primary_expression
|
||||||
| array_creation_expression ;
|
| array_creation_expression ;
|
||||||
|
|
||||||
texpr:
|
|
||||||
tmember ;
|
|
||||||
|
|
||||||
//tinvocation:
|
|
||||||
// te1=telement arguments? (access_operator te2=telement arguments?)*;
|
|
||||||
|
|
||||||
tinvocation:
|
|
||||||
tmember tinvocation_part? ;
|
|
||||||
tinvocation_part:
|
|
||||||
arguments+ (access_operator! tinvocation)
|
|
||||||
| arguments+ telement_part
|
|
||||||
| arguments+ ;
|
|
||||||
|
|
||||||
telement:
|
|
||||||
tmember telement_part? ;
|
|
||||||
telement_part:
|
|
||||||
bracket_expression+ (access_operator telement) -> ^(TELEMENT bracket_expression+ telement)
|
|
||||||
| bracket_expression+ tinvocation_part -> ^(TELEMENT bracket_expression+ tinvocation_part)
|
|
||||||
| bracket_expression+ -> ^(TELEMENT bracket_expression) ;
|
|
||||||
|
|
||||||
tmember:
|
|
||||||
identifier (access_operator identifier)* -> ^(TMEMBER identifier+) ;
|
|
||||||
|
|
||||||
primary_expression:
|
primary_expression:
|
||||||
primary_expression_start primary_expression_part*
|
primary_expression_start primary_expression_part* -> ^(PRIMARY primary_expression_start primary_expression_part*)
|
||||||
| delegate_creation_expression // new FooDelegate (int X, string Y)
|
| delegate_creation_expression // new FooDelegate (int X, string Y)
|
||||||
| anonymous_object_creation_expression // new {int X, string Y}
|
| anonymous_object_creation_expression // new {int X, string Y}
|
||||||
| sizeof_expression // sizeof (struct)
|
| sizeof_expression // sizeof (struct)
|
||||||
@ -358,7 +345,7 @@ brackets_or_arguments:
|
|||||||
access_operator:
|
access_operator:
|
||||||
'.' | '->' ;
|
'.' | '->' ;
|
||||||
arguments:
|
arguments:
|
||||||
'(' argument_list? ')' ;
|
'(' argument_list? ')' -> ^(ARGUMENTS argument_list*) ;
|
||||||
bracket_expression:
|
bracket_expression:
|
||||||
'[' expression_list? ']' ;
|
'[' expression_list? ']' ;
|
||||||
|
|
||||||
@ -552,8 +539,6 @@ array_initializer:
|
|||||||
variable_initializer_list:
|
variable_initializer_list:
|
||||||
variable_initializer (',' variable_initializer)* ;
|
variable_initializer (',' variable_initializer)* ;
|
||||||
// >>= check needed (no whitespace)
|
// >>= check needed (no whitespace)
|
||||||
assignment_operator:
|
|
||||||
'=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>' '>=' ;
|
|
||||||
lambda_expression:
|
lambda_expression:
|
||||||
anonymous_function_signature '=>' anonymous_function_body;
|
anonymous_function_signature '=>' anonymous_function_body;
|
||||||
anonymous_function_signature:
|
anonymous_function_signature:
|
||||||
@ -632,8 +617,8 @@ class_modifiers:
|
|||||||
class_modifier:
|
class_modifier:
|
||||||
'new' | 'public' | 'protected' | 'internal' | 'private' | 'abstract' | 'sealed' | 'static' | 'unsafe';
|
'new' | 'public' | 'protected' | 'internal' | 'private' | 'abstract' | 'sealed' | 'static' | 'unsafe';
|
||||||
class_base:
|
class_base:
|
||||||
':' class_type (',' interface_type_list)?
|
':' class_type (',' interface_type_list)? -> ^(CLASS_INHERITANCE class_type interface_type_list?)
|
||||||
| ':' interface_type_list ;
|
| ':' interface_type_list -> ^(CLASS_INHERITANCE interface_type_list) ;
|
||||||
interface_type_list:
|
interface_type_list:
|
||||||
t += type_name (',' t += type_name)*
|
t += type_name (',' t += type_name)*
|
||||||
-> $t+;
|
-> $t+;
|
||||||
@ -684,6 +669,11 @@ constant_modifiers:
|
|||||||
constant_modifier+ ;
|
constant_modifier+ ;
|
||||||
constant_modifier:
|
constant_modifier:
|
||||||
'new' | 'public' | 'protected' | 'internal' | 'private' ;
|
'new' | 'public' | 'protected' | 'internal' | 'private' ;
|
||||||
|
constant_declarators:
|
||||||
|
constant_declarator (',' constant_declarator)* ;
|
||||||
|
constant_declarator:
|
||||||
|
identifier ('=' constant_expression)? ;
|
||||||
|
|
||||||
field_declaration:
|
field_declaration:
|
||||||
attributes? field_modifiers? type variable_declarators ';'
|
attributes? field_modifiers? type variable_declarators ';'
|
||||||
-> ^(FIELD_DECL attributes? field_modifiers? type variable_declarators)
|
-> ^(FIELD_DECL attributes? field_modifiers? type variable_declarators)
|
||||||
@ -693,10 +683,10 @@ field_modifiers:
|
|||||||
field_modifier:
|
field_modifier:
|
||||||
'new' | 'public' | 'protected' | 'internal' | 'private' | 'static' | 'readonly' | 'volatile' | 'unsafe' ;
|
'new' | 'public' | 'protected' | 'internal' | 'private' | 'static' | 'readonly' | 'volatile' | 'unsafe' ;
|
||||||
variable_declarators:
|
variable_declarators:
|
||||||
variable_declarator (',' variable_declarator)* ;
|
vd += variable_declarator (',' vd += variable_declarator)* -> $vd+;
|
||||||
variable_declarator:
|
variable_declarator:
|
||||||
// identifier ('=' variable_initializer)? ;
|
// identifier ('=' variable_initializer)? ;
|
||||||
type_name ('=' variable_initializer)? ; // eg. event EventHandler IInterface.VariableName;
|
type_name ('=' variable_initializer)? -> ^(VARIABLE_DECLARATOR type_name ('=' variable_initializer)?) ; // eg. event EventHandler IInterface.VariableName;
|
||||||
variable_initializer:
|
variable_initializer:
|
||||||
expression | array_initializer ;
|
expression | array_initializer ;
|
||||||
// | literal ;
|
// | literal ;
|
||||||
@ -704,9 +694,9 @@ method_declarations:
|
|||||||
method_declaration+ ;
|
method_declaration+ ;
|
||||||
method_declaration:
|
method_declaration:
|
||||||
method_header method_body
|
method_header method_body
|
||||||
-> ^(METHOD_DECL method_header method_body);
|
-> ^(METHOD_DECL method_header method_body?);
|
||||||
method_header:
|
method_header:
|
||||||
attributes? method_modifiers? 'partial'? return_type (member_name | 'get' | 'set') generic_parameter_list?
|
attributes? method_modifiers? 'partial'? return_type member_name generic_parameter_list?
|
||||||
'(' formal_parameter_list? ')' type_parameter_constraints_clauses? ;
|
'(' formal_parameter_list? ')' type_parameter_constraints_clauses? ;
|
||||||
method_modifiers:
|
method_modifiers:
|
||||||
method_modifier+ ;
|
method_modifier+ ;
|
||||||
@ -714,27 +704,30 @@ method_modifier:
|
|||||||
'new' | 'public' | 'protected' | 'internal' | 'private' | 'static' | 'virtual' | 'sealed' | 'override'
|
'new' | 'public' | 'protected' | 'internal' | 'private' | 'static' | 'virtual' | 'sealed' | 'override'
|
||||||
| 'abstract' | 'extern' | 'unsafe' ;
|
| 'abstract' | 'extern' | 'unsafe' ;
|
||||||
return_type:
|
return_type:
|
||||||
type -> ^(RETURN_TYPE type)
|
type
|
||||||
| 'void' '*'* -> ^(RETURN_TYPE 'void' '*'*);
|
| 'void' '*'* -> ^(TYPE ^(PREDEFINED_TYPE 'void' '*'*));
|
||||||
method_body:
|
method_body:
|
||||||
block ;
|
block ;
|
||||||
formal_parameter_list:
|
formal_parameter_list:
|
||||||
fp += formal_parameter (',' fp += formal_parameter)*
|
fp += formal_parameter (',' fp += formal_parameter)*
|
||||||
-> $fp+ ;
|
-> $fp+ ;
|
||||||
formal_parameter:
|
formal_parameter:
|
||||||
fixed_parameter | parameter_array | '__arglist'; // __arglist is undocumented, see google
|
fixed_parameter
|
||||||
|
| parameter_array
|
||||||
|
| '__arglist'; // __arglist is undocumented, see google
|
||||||
fixed_parameters:
|
fixed_parameters:
|
||||||
fixed_parameter+ ;
|
fixed_parameter+ ;
|
||||||
// 4.0
|
// 4.0
|
||||||
fixed_parameter:
|
fixed_parameter:
|
||||||
attributes? parameter_modifier? type identifier default_argument?;
|
attributes? parameter_modifier? type identifier default_argument?
|
||||||
|
-> ^(FIXED_PARAMETER attributes? parameter_modifier? type identifier default_argument?) ;
|
||||||
// 4.0
|
// 4.0
|
||||||
default_argument:
|
default_argument:
|
||||||
'=' expression;
|
'=' expression;
|
||||||
parameter_modifier:
|
parameter_modifier:
|
||||||
'ref' | 'out' | 'this' ;
|
'ref' | 'out' | 'this' ;
|
||||||
parameter_array:
|
parameter_array:
|
||||||
attributes? 'params'? array_type identifier ;
|
attributes? 'params' type identifier ;
|
||||||
property_declaration:
|
property_declaration:
|
||||||
attributes? property_modifiers? type member_name '{' accessor_declarations '}'
|
attributes? property_modifiers? type member_name '{' accessor_declarations '}'
|
||||||
-> ^(PROPERTY_DECLARATION attributes? property_modifiers? type member_name '{' accessor_declarations '}') ;
|
-> ^(PROPERTY_DECLARATION attributes? property_modifiers? type member_name '{' accessor_declarations '}') ;
|
||||||
@ -952,7 +945,7 @@ fixed_pointer_initializer:
|
|||||||
unsafe_statement:
|
unsafe_statement:
|
||||||
'unsafe' block;
|
'unsafe' block;
|
||||||
block:
|
block:
|
||||||
';' -> ^(BLOCK)
|
';' ->
|
||||||
| '{' statement_list? '}' -> ^(BLOCK statement_list?);
|
| '{' statement_list? '}' -> ^(BLOCK statement_list?);
|
||||||
statement_list:
|
statement_list:
|
||||||
statement+ ;
|
statement+ ;
|
||||||
@ -964,7 +957,8 @@ declaration_statement:
|
|||||||
(local_variable_declaration
|
(local_variable_declaration
|
||||||
| local_constant_declaration) ';' ;
|
| local_constant_declaration) ';' ;
|
||||||
local_variable_declaration:
|
local_variable_declaration:
|
||||||
local_variable_type local_variable_declarators ;
|
local_variable_type local_variable_declarators ->
|
||||||
|
^(LOCAL_VAR local_variable_type local_variable_declarators);
|
||||||
local_variable_type:
|
local_variable_type:
|
||||||
type
|
type
|
||||||
| 'var'
|
| 'var'
|
||||||
@ -982,11 +976,6 @@ stackalloc_initializer:
|
|||||||
'stackalloc' unmanaged_type '[' expression ']' ;
|
'stackalloc' unmanaged_type '[' expression ']' ;
|
||||||
local_constant_declaration:
|
local_constant_declaration:
|
||||||
'const' type constant_declarators ;
|
'const' type constant_declarators ;
|
||||||
constant_declarators:
|
|
||||||
constant_declarator (',' constant_declarator)* ;
|
|
||||||
constant_declarator:
|
|
||||||
identifier ('=' constant_expression)? ;
|
|
||||||
// identifier ('=' literal)? ;
|
|
||||||
expression_statement:
|
expression_statement:
|
||||||
expression ';' ;
|
expression ';' ;
|
||||||
statement_expression:
|
statement_expression:
|
||||||
@ -1086,8 +1075,8 @@ yield_statement:
|
|||||||
| ('yield' 'break' ';') ;
|
| ('yield' 'break' ';') ;
|
||||||
|
|
||||||
identifier:
|
identifier:
|
||||||
IDENTIFIER
|
IDENTIFIER -> ^(ID IDENTIFIER)
|
||||||
| also_keyword ;
|
| also_keyword -> ^(ID also_keyword);
|
||||||
|
|
||||||
literal:
|
literal:
|
||||||
Real_literal
|
Real_literal
|
||||||
@ -1106,10 +1095,10 @@ keyword:
|
|||||||
|
|
||||||
also_keyword:
|
also_keyword:
|
||||||
'add' | 'alias' | 'assembly' | 'module' | 'field' | 'event' | 'method' | 'param' | 'property' | 'type'
|
'add' | 'alias' | 'assembly' | 'module' | 'field' | 'event' | 'method' | 'param' | 'property' | 'type'
|
||||||
| 'yield' | 'from' | 'into' | 'join' | 'on' | 'where' | 'orderby' | 'group' | 'by' | 'ascending' | 'descending'
|
| 'yield' | 'from' | 'into' | 'join' | 'on' | 'where' | 'orderby' | 'group' | 'by' | 'ascending'
|
||||||
| 'equals' | 'select' | 'pragma' | 'let' | 'remove' | 'set' | 'var' | '__arglist';
|
| 'descending' | 'equals' | 'select' | 'pragma' | 'let' | 'remove' | 'set' | 'var' | '__arglist' | 'dynamic';
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
// Lexer Section
|
// Lexar Section
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
|
|
||||||
TRUE : 'true';
|
TRUE : 'true';
|
||||||
|
@ -1,21 +1,15 @@
|
|||||||
|
|
||||||
-- Rebuild cs parser
|
-- Rebuild cs parser
|
||||||
|
cd "C:\Documents and Settings\developer\My Documents\gitrepos\cs2j\CSharpTranslator\antlr3\src\cs2j\CSharp"
|
||||||
|
java -Xmx512m -jar ..\..\..\jar\antlr-3.3.jar cs.g
|
||||||
|
|
||||||
cd My\ Documents/gitrepos/cs2j/CSharpTranslator/antlr3
|
-- parse one file
|
||||||
|
|
||||||
java -Xmx512m -jar jar\antlr-3.2.jar src\cs2j\CSharp\cs.g
|
|
||||||
java -Xmx512m -jar jar\antlr-3.2.jar -debug src\cs2j\CSharp\cs.g
|
|
||||||
|
|
||||||
-- From git bash
|
|
||||||
java -Xmx512m -jar jar/antlr-3.2.jar -fo src/cs2j/CSharp src/cs2j/CSharp/cs.g
|
|
||||||
|
|
||||||
src\cs2j\bin\Debug\cs2j.exe -netdir "c:\Documents and Settings\DevUser\My Documents\TrunkBranch\CS2JLibrary" -appdir "c:\Documents and Settings\DevUser\My Documents\Visual Studio 2005\Projects\ScormEngineNetTrunk\src\app\ScormEngine.Core" "c:\Documents and Settings\DevUser\My Documents\Visual Studio 2005\Projects\ScormEngineNetTrunk\src\app\ScormEngine.Core\Logic"
|
|
||||||
|
|
||||||
C:\Documents and Settings\DevUser\My Documents\gitrepos\CSharpTranslator>src\cs2
|
|
||||||
j\bin\Debug\cs2j.exe -netdir "c:\Documents and Settings\DevUser\My Documents\Tru
|
|
||||||
nkBranch\CS2JLibrary" -appdir "c:\Documents and Settings\DevUser\My Documents\Vi
|
|
||||||
sual Studio 2005\Projects\ScormEngineNetTrunk\src\app\ScormEngine.Core\Util\Cach
|
|
||||||
ing\NullCache.cs" "c:\Documents and Settings\DevUser\My Documents\Visual Studio
|
|
||||||
2005\Projects\ScormEngineNetTrunk\src\app\ScormEngine.Core\Logic"
|
|
||||||
|
|
||||||
src\cs2j\bin\Debug\cs2j.exe -mindriver C:\Documents and Settings\DevUser\My Documents\kgtemp\getClass.cs
|
src\cs2j\bin\Debug\cs2j.exe -mindriver C:\Documents and Settings\DevUser\My Documents\kgtemp\getClass.cs
|
||||||
|
|
||||||
|
-- parse Logic
|
||||||
|
|
||||||
|
cd "C:\Documents and Settings\developer\My Documents\gitrepos\cs2j\CSharpTranslator\antlr3"
|
||||||
|
|
||||||
|
src\cs2j\bin\Debug\cs2j.exe -netdir "c:\Documents and Settings\s\developer\My Documents\gitrepos\cs2j\CS2JLibrary\NetTranslations" -appdir "c:\Documents and Settings\developer\My Documents\Visual Studio 2005\Projects\ScormEngineNetTrunk\src\app\ScormEngine.Core" "c:\Documents and Settings\developer\My Documents\Visual Studio 2005\Projects\ScormEngineNetTrunk\src\app\ScormEngine.Core\Logic"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user