Skip to content

Commit

Permalink
updated javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
stigito committed Mar 23, 2018
1 parent 247fbf7 commit bd8eddf
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 45 deletions.
Binary file modified bin/edu/hm/stiglmeier/andreas/praeproc/PraeProzessor.class
Binary file not shown.
107 changes: 62 additions & 45 deletions src/edu/hm/stiglmeier/andreas/praeproc/PraeProzessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,74 @@
import edu.hm.cs.rs.compiler.toys.base.Source;

/**
* dummy javadoc.
* @author Stigi
* This Class Represents a Praeprocesser in a Compiler.
* Use the Method process(Source unprocessed).
* @author Andreas Stiglmeier
*
*/
public class PraeProzessor implements Preprocessor {

/**
* dummy javadoc.
* @author Stigi
* States used in the implementation of the Praeprocessor.
* @author Andreas Stiglmeier
*
*/
private enum STATE {

/**
* dummy.
* This State represents the normal processing of code with no comment.
*/
NORMAL(0),
/**
* dummy.
* This State represents the possibility of currently reading a comment symbolised by the first occurence of '/'.
*/
COMM(1),
/**
* dummy.
* This State represents the currently reading of a Comment Line : // ...
*/
COMMLINE(2),
/**
* dummy.
* This State represents the currently reading of a Comment Block : /* ...
*/
COMMBLOCK(3),
/**
* dummy.
* This State represents the currently reading of a Comment Block with the possibility of ending that block : /* ... *.
*/
COMMBLOCKEND(4);

/**
* dummy.
* the integer value representing the state.
*/
private final int state;

/**
* dummy javadoc.
* @param state dummy.
* Constructor.
* @param state the integer value representing the state.
*/
STATE(int state) {
this.state = state;
}

/**
* dummy javadoc.
* @return dummy.
* Getter for the integer value representing the state.
* @return state as int.
*/
private int getState() {
return state;
}
}

/**
* dummy javadoc.
* default constructor.
*/
public PraeProzessor() {

}

/**
* dummy javadoc.
* @param unprocessed dummy.
* Method for processing the pipeline in a compiler.
* @param unprocessed Source with sourcecode.
* @return Source without comments.
*/
@Override
public Source process(Source unprocessed) throws LexicalError {
Expand All @@ -93,10 +95,11 @@ public Source process(Source unprocessed) throws LexicalError {
}

/**
* dummy javadoc.
* @param character dummy.
* @param processed dummy.
* @return dummy.
* This Method processes the currently read character and selects the handling method depending on the current state of the automat.
* @param character currently read character.
* @param processed Source from where the character was read.
* @param state current state of the automat.
* @return new state of the automat.
*/
private int processChar(Source processed, char character, int state) {
switch(state) {
Expand All @@ -116,10 +119,12 @@ private int processChar(Source processed, char character, int state) {
}

/**
* dummy javadoc.
* @param character dummy.
* @param processed dummy.
* @return dummy.
* This Method handles the "normal" processing state of the automat.
* When a '/' occures, no character is processed and the state of the automat changes to STATE.COMM,
* otherwise the character is appended to the Output Source and the state of the automat changes to STATE.NORMAL
* @param character currently read character.
* @param processed Output Source.
* @return new state of the automat.
*/
private int processNormal(Source processed, char character) {
if (character == '/') {
Expand All @@ -132,10 +137,13 @@ private int processNormal(Source processed, char character) {
}

/**
* dummy javadoc.
* @param character dummy.
* @param processed dummy.
* @return dummy.
* This Method handles the STATE.COMM processing state of the automat.
* When a '/' occures, no character is processed and the state of the automat changes to STATE.COMMLINE
* When a '*' occures, no character is processed and the state of the automat changes to STATE.COMMBLOCK
* otherwise the character is appended to the Output Source and the state of the automat changes to STATE.NORMAL
* @param character currently read character.
* @param processed Output Source.
* @return new state of the automat.
*/
private int processComm(Source processed, char character) {
if (character == '/') {
Expand All @@ -151,10 +159,12 @@ else if (character == '*') {
}

/**
* dummy javadoc.
* @param character dummy.
* @param processed dummy.
* @return dummy.
* This Method handles the STATE.COMMLINE processing state of the automat.
* When a '\n' occures, the character is appended to the Output Source and the state of the automat changes to STATE.NORMAL
* otherwise no character is processed and the state of the automat changes to STATE.COMMLINE
* @param character currently read character.
* @param processed Output Source.
* @return new state of the automat.
*/
private int processCommLine(Source processed, char character) {
if (character == '\n') {
Expand All @@ -167,10 +177,13 @@ private int processCommLine(Source processed, char character) {
}

/**
* dummy javadoc.
* @param character dummy.
* @param processed dummy.
* @return dummy.
* This Method handles the STATE.COMMBLOCK processing state of the automat.
* When a '*' occures, no character is processed and the state of the automat changes to STATE.COMMBLOCKEND
* When a '\n' occures, the character is appended to the Output Soruce and the state of the automat changes to STATE.COMMBLOCK,
* otherwise no character is processede and the state of the automat changes to STATE.COMMBLOCK
* @param character currently read character.
* @param processed Output Source.
* @return new state of the automat.
*/
private int processCommBlock(Source processed, char character) {
if (character == '*') {
Expand All @@ -184,10 +197,14 @@ else if (character == '\n') {
}

/**
* dummy javadoc.
* @param character dummy.
* @param processed dummy.
* @return dummy.
* This Method handles the STATE.COMMBLOCEND processing state of the automat.
* When a '/' occures, a whitespace character is appended to the Output Source and the state of the automat changes to STATE.NORMAL,
* When a '*' occures, no character is processed and the state of the automat changes to STATE.COMMBLOCKEND,
* When a '\n' occures, the character is appended to the Output Soruce and the state of the automat changes to STATE.COMMBLOCK,
* otherwise no character is processed and the state of the automat changes to STATE.COMMBLOCK
* @param character currently read character.
* @param processed Output Source.
* @return new state of the automat.
*/
private int processCommBlockEnd(Source processed, char character) {
if (character == '/') {
Expand All @@ -205,10 +222,10 @@ else if (character == '\n') {
}

/**
* dummy javadoc.
* @param character dummy.
* @param processed dummy.
* @return dummy.
* Method to box appending a character and changing the state of the automat to STATE.NORMAL.
* @param character currently read character.
* @param processed Output Source.
* @return new state of the automat.
*/
private int proceedNormal(Source processed, char character) {
processed.append(character);
Expand Down

0 comments on commit bd8eddf

Please sign in to comment.