[DEV] add for generating with wrong condition ... but brace work
This commit is contained in:
parent
61cc132991
commit
7dfafbefdd
@ -529,6 +529,54 @@ int32_t estyle::Generator::process(int32_t _startId,
|
||||
m_output += type;
|
||||
continue;
|
||||
}
|
||||
if (elem == estyle::lexer::RESERVED_FOR) {
|
||||
addNewLineIfSemiColon();
|
||||
addSpace();
|
||||
m_output += "for ";
|
||||
typePush("for");
|
||||
offsetPush(4);
|
||||
// TODO : do this ==> not implemented
|
||||
for (int64_t jjj=iii+1; jjj<m_lexer.size(); ++jjj) {
|
||||
enum estyle::lexer::tocken elem = m_lexer.getTocken(jjj);
|
||||
if (elem == estyle::lexer::RESERVED_NEW_LINE) {
|
||||
// OK ==> normal case ...
|
||||
} else if (elem == estyle::lexer::PARENTHESE_IN) {
|
||||
// find condition section ...
|
||||
iii = generateCondition(jjj);
|
||||
break;
|
||||
} else {
|
||||
ESTYLE_ERROR("Get 'for' without '(' element");
|
||||
}
|
||||
}
|
||||
offsetPop();
|
||||
bool needBrace = false;
|
||||
bool haveBrace = false;
|
||||
int32_t subGenerationStart = iii+1;
|
||||
int32_t subGenerationStop = iii+1;
|
||||
// Check if next action is inside {} or not ...
|
||||
if (nextIs(iii+1, estyle::lexer::BRACE_IN) == true) {
|
||||
haveBrace = true;
|
||||
// no need to add one ...
|
||||
int32_t countAction = countCurrent(iii+1, estyle::lexer::tocken::SEMICOLON);
|
||||
if (countAction != 1) {
|
||||
needBrace = true;
|
||||
}
|
||||
subGenerationStart = iii+2;
|
||||
subGenerationStop = endOfSection(iii+1);
|
||||
} else {
|
||||
// only 1 instruction:
|
||||
int32_t sectionEnd = endOfAction(iii+1);
|
||||
subGenerationStop = sectionEnd+1;
|
||||
}
|
||||
iii = generateBrace(subGenerationStart, subGenerationStop, needBrace, true);
|
||||
if (haveBrace == true) {
|
||||
iii--;
|
||||
} else {
|
||||
iii -= 2;
|
||||
}
|
||||
typePop();
|
||||
continue;
|
||||
}
|
||||
if (elem == estyle::lexer::RESERVED_IF) {
|
||||
addNewLineIfSemiColon();
|
||||
addSpace();
|
||||
|
@ -26,7 +26,7 @@ TEST(testBraceFor, brace_for_0000) {
|
||||
//interface.properties.set("brace-for-out-space-before", "true");
|
||||
//interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;){action_B;}action_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; ){action_B;}action_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -44,7 +44,7 @@ TEST(testBraceFor, brace_for_1000) {
|
||||
//interface.properties.set("brace-for-out-space-before", "true");
|
||||
//interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;)\n{action_B;\n}action_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; )\n{action_B;\n}action_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -62,7 +62,7 @@ TEST(testBraceFor, brace_for_1010) {
|
||||
interface.properties.set("brace-for-out-space-before", "true");
|
||||
//interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;)\n{action_B;\n}action_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; )\n{action_B;\n}action_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -80,7 +80,7 @@ TEST(testBraceFor, brace_for_1011) {
|
||||
interface.properties.set("brace-for-out-space-before", "true");
|
||||
interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;)\n{ action_B;\n} action_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; )\n{ action_B;\n} action_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -98,7 +98,7 @@ TEST(testBraceFor, brace_for_1100) {
|
||||
//interface.properties.set("brace-for-out-space-before", "true");
|
||||
//interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;)\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; )\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -116,7 +116,7 @@ TEST(testBraceFor, brace_for_1101) {
|
||||
//interface.properties.set("brace-for-out-space-before", "true");
|
||||
interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;)\n{ \n\taction_B;\n} \naction_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; )\n{ \n\taction_B;\n} \naction_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -134,7 +134,7 @@ TEST(testBraceFor, brace_for_1110) {
|
||||
interface.properties.set("brace-for-out-space-before", "true");
|
||||
//interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;)\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; )\n{\n\taction_B;\n}\naction_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -152,7 +152,7 @@ TEST(testBraceFor, brace_for_1111) {
|
||||
interface.properties.set("brace-for-out-space-before", "true");
|
||||
interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;)\n{ \n\taction_B;\n} \naction_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; )\n{ \n\taction_B;\n} \naction_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -170,7 +170,7 @@ TEST(testBraceFor, brace_for_1001) {
|
||||
//interface.properties.set("brace-for-out-space-before", "true");
|
||||
interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;)\n{ action_B;\n} action_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; )\n{ action_B;\n} action_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -189,7 +189,7 @@ TEST(testBraceFor, brace_for_0100) {
|
||||
//interface.properties.set("brace-for-out-space-before", "true");
|
||||
//interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;){\n\taction_B;}\naction_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; ){\n\taction_B;}\naction_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -207,7 +207,7 @@ TEST(testBraceFor, brace_for_0101) {
|
||||
//interface.properties.set("brace-for-out-space-before", "true");
|
||||
interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;){ \n\taction_B;} \naction_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; ){ \n\taction_B;} \naction_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -225,7 +225,7 @@ TEST(testBraceFor, brace_for_0110) {
|
||||
interface.properties.set("brace-for-out-space-before", "true");
|
||||
//interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;) {\n\taction_B; }\naction_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; ) {\n\taction_B; }\naction_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -243,7 +243,7 @@ TEST(testBraceFor, brace_for_0010) {
|
||||
interface.properties.set("brace-for-out-space-before", "true");
|
||||
//interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;) {action_B; }action_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; ) {action_B; }action_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -261,7 +261,7 @@ TEST(testBraceFor, brace_for_0011) {
|
||||
interface.properties.set("brace-for-out-space-before", "true");
|
||||
interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;) { action_B; } action_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; ) { action_B; } action_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -279,7 +279,7 @@ TEST(testBraceFor, brace_for_0111) {
|
||||
interface.properties.set("brace-for-out-space-before", "true");
|
||||
interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;) { \n\taction_B; } \naction_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; ) { \n\taction_B; } \naction_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
@ -297,7 +297,7 @@ TEST(testBraceFor, brace_for_0001) {
|
||||
//interface.properties.set("brace-for-out-space-before", "true");
|
||||
interface.properties.set("brace-for-out-space-after", "true");
|
||||
//interface.properties.set("brace-for-single", "true");
|
||||
etk::String outputRef = "action_A;\nfor (;;){ action_B;} action_D;";
|
||||
etk::String outputRef = "action_A;\nfor (;\n; ){ action_B;} action_D;";
|
||||
etk::String output = interface.process(sourceFor1Action);
|
||||
EXPECT_EQ(output, outputRef);
|
||||
output = interface.process(sourceFor1ActionNoBrace);
|
||||
|
Loading…
Reference in New Issue
Block a user