Skip to content

Commit

Permalink
fixed parallel test
Browse files Browse the repository at this point in the history
  • Loading branch information
stigito committed Mar 22, 2018
1 parent bcf1fdb commit d7949f4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 61 deletions.
Binary file modified bin/edu/hm/stiglmeier/andreas/praeproc/PraeProzessor.class
Binary file not shown.
97 changes: 37 additions & 60 deletions src/edu/hm/stiglmeier/andreas/praeproc/PraeProzessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ private int getState() {
}
}

/**
* dummy.
*/
private String buffer = "";

/**
* dummy.
*/
private int state;

/**
* dummy javadoc.
*/
Expand All @@ -85,10 +75,10 @@ public PraeProzessor() {
public Source process(Source unprocessed) throws LexicalError {

final Source processed = new Source();
state = STATE.NORMAL.getState(); // resetting automat
buffer = "";
int state = STATE.NORMAL.getState(); // resetting automat
String buffer = "";
while(unprocessed.hasMore()) {
processed.append(processChar(unprocessed.getNextChar()));
state = processChar(processed, unprocessed.getNextChar(), state);
}

if(state >= 2) {
Expand All @@ -103,20 +93,20 @@ public Source process(Source unprocessed) throws LexicalError {
* @param character dummy.
* @return dummy.
*/
private String processChar(char character) {
private int processChar(Source processed, char character, int state) {
switch(state) {
case 0:
return processNormal(character);
return processNormal(processed, character);
case 1:
return processComm(character);
return processComm(processed, character);
case 2:
return processCommLine(character);
return processCommLine(processed, character);
case 3:
return processCommBlock(character);
return processCommBlock(processed, character);
case 4:
return processCommBlockEnd(character);
return processCommBlockEnd(processed, character);
default:
return processNormal(character);
return processNormal(processed, character);
}
}

Expand All @@ -125,14 +115,12 @@ private String processChar(char character) {
* @param character dummy.
* @return dummy.
*/
private String processNormal(char character) {
private int processNormal(Source processed, char character) {
if (character == '/') {
buffer += character;
state = STATE.COMM.getState();
return "";
return STATE.COMM.getState();
}
else {
return proceedNormal(character);
return proceedNormal(processed, character);
}

}
Expand All @@ -142,33 +130,30 @@ private String processNormal(char character) {
* @param character dummy.
* @return dummy.
*/
private String processComm(char character) {
private int processComm(Source processed, char character) {
if (character == '/') {
state = STATE.COMMLINE.getState();
return STATE.COMMLINE.getState();
}
else if(character == '*') {
state = STATE.COMMBLOCK.getState();
return STATE.COMMBLOCK.getState();
}
else {
state = STATE.NORMAL.getState();
return proceedNormal(character);
processed.append('/');
return proceedNormal(processed, character);
}
buffer = "";
return "";
}

/**
* dummy javadoc.
* @param character dummy.
* @return dummy.
*/
private String processCommLine(char character) {
private int processCommLine(Source processed, char character) {
if (character == '\n') {
state = STATE.NORMAL.getState();
return proceedNormal(character);
return STATE.NORMAL.getState();
}
else {
return "";
return STATE.COMMLINE.getState();
}
}

Expand All @@ -177,53 +162,45 @@ private String processCommLine(char character) {
* @param character dummy.
* @return dummy.
*/
private String processCommBlock(char character) {
private int processCommBlock(Source processed, char character) {
if (character == '*') {
state = STATE.COMMBLOCKEND.getState();
return "";
return STATE.COMMBLOCKEND.getState();
}
else if (character == '\n') {
return proceedNormal(character);
}
else {
return "";
processed.append(character);
}
return STATE.COMMBLOCK.getState();

}

/**
* dummy javadoc.
* @param character dummy.
* @return dummy.
*/
private String processCommBlockEnd(char character) {
private int processCommBlockEnd(Source processed, char character) {
if (character == '/') {
state = STATE.NORMAL.getState();
buffer = "";
return " ";
}
else if (character == '\n') {
state = STATE.COMMBLOCK.getState();
return proceedNormal(character);
processed.append(' ');
return STATE.NORMAL.getState();
}
else if(character == '*') {
state = STATE.COMMBLOCKEND.getState();
return "";
return STATE.COMMBLOCKEND.getState();
}
else {
state = STATE.COMMBLOCK.getState();
return "";
else if (character == '\n') {
processed.append(character);
}
return STATE.COMMBLOCK.getState();

}

/**
* dummy javadoc.
* @param character dummy.
* @return dummy.
*/
private String proceedNormal(char character) {
final String s = new String(buffer);
buffer = "";
return s + character;
private int proceedNormal(Source processed, char character) {
processed.append(character);
return STATE.NORMAL.getState();
}


Expand Down
6 changes: 5 additions & 1 deletion test.mini
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/*//*$**/x
/***/x
/x
// sdsaf
// / scsv// aja
var/*xyz * haha */variable

0 comments on commit d7949f4

Please sign in to comment.