1
0
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:
Kevin Glynn 2010-11-24 07:42:25 +01:00
parent cf86542a32
commit 69955f78ff

View File

@ -65,6 +65,22 @@ scope NSContext {
}
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"; }
;
identifier:
identifier
@after {
string fixedId = fixBrokenId($identifier.tree.Token.Text);
$identifier.tree.Token.Text = fixedId;
}:
IDENTIFIER | also_keyword;
keyword: