b) Interface construct
@Begin
- @Interface: ...
+ @Interface_decl: ...
@Commit_point_set:
IDENTIFIER | IDENTIFIER ...
@Condition: ... (Optional)
@Begin
@Interface_define: <Interface_Name>
@End
+
+ g) Interface declare & define construct
+ @Begin
+ @Interface_decl_define: <Interface_Name>
+ @Commit_point_set:
+ IDENTIFIER | IDENTIFIER ...
+ @Condition: ... (Optional)
+ @HB_Condition:
+ IDENTIFIER :: <C_CPP_Condition>
+ @HB_Condition: ...
+ @ID: ... (Optional, use default ID)
+ @Check: (Optional)
+ ...
+ @Action: (Optional)
+ ...
+ @Post_action: (Optional)
+ @Post_check: (Optional)
+ @End
+
*/
public static String stringArray2String(ArrayList<String> content) {
StringBuilder sb = new StringBuilder();
+ if (content.size() == 1)
+ return content.get(0);
for (int i = 0; i < content.size(); i++) {
sb.append(content.get(i) + "\n");
}
<UNSIGNED: "unsigned">
|
<TEMPLATE: "template">
+|
+ <INLINE: "inline">
+|
+ <STATIC: "static">
|
<#DIGIT: ["0"-"9"]>
|
<COLON: ":">
|
<DOUBLECOLON: "::">
+|
+ <DOUBLELESSTHAN: "<<">
+|
+ <DOUBLEGREATERTHAN: ">>">
+|
+ <TRIPLEGREATERTHAN: ">>>">
+|
+ <PLUS_EQUALS: "+=">
+|
+ <MINUS_EQUALS: "-=">
+|
+ <TIMES_EQUALS: "*=">
+|
+ <DIVIDE_EQUALS: "/=">
+|
+ <MOD_EQUALS: "%=">
+|
+ <XOR_EQUALS: "^=">
+|
+ <OR_EQUALS: "|=">
+|
+ <AND_EQUALS: "&=">
+
|
<SEMI_COLON: ";">
|
{
System.out.println(func);
}
-
}
}
{
(str = <IDENTIFIER>.image {res = str;})
- ("<" str = <IDENTIFIER>.image { res = res + "<" + str; }
- ("," str = <IDENTIFIER>.image { res = res + ", " + str; })* ">"
+ ("<" str = Type() { res = res + "<" + str; }
+ ("," str = Type() { res = res + ", " + str; })* ">"
{ res = res + ">"; }
)?
{
FunctionHeader FuncDecl() :
{
+ ArrayList<VariableDeclaration> templateList;
String ret;
QualifiedName funcName;
ArrayList<VariableDeclaration> args;
}
{
+aa
+ (<STATIC> | <INLINE>)*
ret = Type()
funcName = ParseQualifiedName()
args = FormalParamList()
}
}
-ArrayList<String> TemplateParamList() :
+ArrayList<VariableDeclaration> TemplateParamList() :
{
- ArrayList<String> params;
- String str;
+ ArrayList<VariableDeclaration> params;
+ String type;
+ String name;
}
{
{
- params = new ArrayList<String>();
+ params = new ArrayList<VariableDeclaration>();
}
<TEMPLATE>
"<"
- (str = <IDENTIFIER>.image
- str = <IDENTIFIER>.image {params.add(str);})
+ (type = <IDENTIFIER>.image
+ name = <IDENTIFIER>.image
+ {
+ params.add(new VariableDeclaration(type, name));
+ }
+ )
- ("," str = <IDENTIFIER>.image
- str = <IDENTIFIER>.image {params.add(str);})*
+ ("," type = <IDENTIFIER>.image
+ name = <IDENTIFIER>.image
+ {
+ params.add(new VariableDeclaration(type, name));
+ }
+ )*
">"
{
//System.out.println(params);
(
t = <CONST> | t = <STRUCT> | t = <CLASS> | t = <UNSIGNED> |
(t = <TEMPLATE> { inTemplate = true; })|
+ t = <STATIC> | t = <INLINE> |
(t = <INCLUDE>
{
header = t.image;
t = <GREATER_EQUALS> | t = <LESS_EQUALS> |
t = <LOGICAL_EQUALS> | t = <NOT_EQUALS> | t = <LOGICAL_AND> | t = <LOGICAL_OR> | t = <XOR> |
t = <QUESTION_MARK> | t = <COLON> | t = <DOUBLECOLON> |
+ t = <DOUBLELESSTHAN> |
+ t = <DOUBLEGREATERTHAN> |
+ t = <TRIPLEGREATERTHAN> |
+
+ t = <PLUS_EQUALS> |
+ t = <MINUS_EQUALS> |
+ t = <TIMES_EQUALS> |
+ t = <DIVIDE_EQUALS> |
+ t = <MOD_EQUALS> |
+ t = <XOR_EQUALS> |
+ t = <OR_EQUALS> |
+ t = <AND_EQUALS> |
+
(t = <SEMI_COLON> { newLine = true; } )
| t = <STRING_LITERAL> | t = <CHARACTER_LITERAL> |
t = <INTEGER_LITERAL> | t = <FLOATING_POINT_LITERAL> |
(t = <DEFINE> { newLine = true; } )
)
{
- text = text + " " + t.image;
+ if (text.equals("")) {
+ text = t.image;
+ } else {
+ text = text + " " + t.image;
+ }
if (newLine) {
content.add(text);
text = "";
newLine = false;
+ inTemplate = false;
}
}
)+
{
hbConditionLabel = "";
}
- interfaceName = <IDENTIFIER>.image (<OPEN_BRACKET> hbConditionLabel =
- <IDENTIFIER>.image <CLOSE_BRACKET>)?
+ interfaceName = <IDENTIFIER>.image (<OPEN_PAREN> hbConditionLabel =
+ <IDENTIFIER>.image <CLOSE_PAREN>)?
{
return new ConditionalInterface(interfaceName, hbConditionLabel);
}
}
{
(clusterName= <IDENTIFIER>.image)
- <EQUALS> <OPEN_PAREN>
+ <EQUALS> <OPEN_BRACE>
(condInterface = Conditional_interface()
{ inst.addInterface2Cluster(clusterName, condInterface); }
)
(<COMMA> condInterface = Conditional_interface()
{ inst.addInterface2Cluster(clusterName, condInterface); }
)*
- <CLOSE_PAREN>
+ <CLOSE_BRACE>
}
void Interface_clusters(GlobalConstruct inst) :
(<CONDITION> (content = C_CPP_CODE(null) { condition = stringArray2String(content); }))?
(
<HB_CONDITION>
- (hbLabel = <IDENTIFIER>.image)
+ (hbLabel = <IDENTIFIER>.image) <DOUBLECOLON>
(content = C_CPP_CODE(null) { hbCondition = stringArray2String(content); })
{
if (hbConditions.containsKey(hbLabel)) {