mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
remove java keywords by prefixing with "__"
This commit is contained in:
parent
cf86542a32
commit
69955f78ff
@ -65,6 +65,22 @@ scope NSContext {
|
|||||||
}
|
}
|
||||||
return stripped;
|
return stripped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Read reserved words from a file so that they can be extended by customer
|
||||||
|
private readonly static string[] javaReserved = new string[] { "int", "protected", "package" };
|
||||||
|
|
||||||
|
protected string fixBrokenId(string id)
|
||||||
|
{
|
||||||
|
// Console.WriteLine(id);
|
||||||
|
foreach (string k in javaReserved)
|
||||||
|
{
|
||||||
|
if (k == id)
|
||||||
|
{
|
||||||
|
return "__" + id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
@ -1191,7 +1207,11 @@ predefined_type returns [string thetext]:
|
|||||||
| 'ushort' { $thetext = "System.UInt16"; }
|
| 'ushort' { $thetext = "System.UInt16"; }
|
||||||
;
|
;
|
||||||
|
|
||||||
identifier:
|
identifier
|
||||||
|
@after {
|
||||||
|
string fixedId = fixBrokenId($identifier.tree.Token.Text);
|
||||||
|
$identifier.tree.Token.Text = fixedId;
|
||||||
|
}:
|
||||||
IDENTIFIER | also_keyword;
|
IDENTIFIER | also_keyword;
|
||||||
|
|
||||||
keyword:
|
keyword:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user