-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from merkrafter/development
0.2.0 pre-release
- Loading branch information
Showing
21 changed files
with
2,474 additions
and
168 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.merkrafter.config; | ||
|
||
/**** | ||
* This enum represents the steps the compiler goes through in order to convert a JavaSST source | ||
* code file into actual byte code. | ||
* | ||
* @version v0.2.0 | ||
* @author merkrafter | ||
***************************************************************/ | ||
public enum CompilerStage { | ||
// CONSTANTS | ||
//============================================================== | ||
/** | ||
* Only scan the input and output tokens. | ||
*/ | ||
SCANNING, | ||
/** | ||
* Scan and parse the input and output whether this was successful. | ||
*/ | ||
PARSING; | ||
|
||
|
||
/** | ||
* @return the lowercase name of this enum item | ||
*/ | ||
@Override | ||
public String toString() { | ||
return name().toLowerCase(); | ||
} | ||
|
||
/** | ||
* Returns the latest stage this enum currently offers in terms of processing data. | ||
* | ||
* @return the latest available compiler stage | ||
*/ | ||
public static CompilerStage latest() { | ||
return PARSING; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.merkrafter.lexing; | ||
|
||
/**** | ||
* This class serves as a token and stores the identifier found. | ||
* | ||
* @version v0.2.0 | ||
* @author merkrafter | ||
***************************************************************/ | ||
public class IdentToken extends Token { | ||
// ATTRIBUTES | ||
//============================================================== | ||
/** | ||
* the identifier this token stands for | ||
*/ | ||
private final String ident; | ||
|
||
// CONSTRUCTORS | ||
//============================================================== | ||
|
||
/**** | ||
* Creates a new IdentToken from an identifier and position data. | ||
***************************************************************/ | ||
public IdentToken(final String ident, final String filename, final long line, | ||
final int position) { | ||
super(TokenType.IDENT, filename, line, position); | ||
this.ident = ident; | ||
} | ||
|
||
// GETTER | ||
//============================================================== | ||
|
||
/** | ||
* @return the identifier this token stands for | ||
*/ | ||
String getIdent() { | ||
return ident; | ||
} | ||
|
||
// METHODS | ||
//============================================================== | ||
// public methods | ||
//-------------------------------------------------------------- | ||
|
||
/** | ||
* Two IdentTokens are equal if both have the type IdentToken and their identifiers, line | ||
* numbers, positions and filenames are equal. | ||
* | ||
* @param obj ideally a IdentToken to compare this with | ||
* @return whether this is equal to obj | ||
*/ | ||
@Override | ||
public boolean equals(final Object obj) { | ||
if (!super.equals(obj)) { | ||
return false; | ||
} | ||
return obj instanceof IdentToken && ((IdentToken) obj).ident.equals(ident); | ||
} | ||
|
||
/** | ||
* Creates a String representation of this IdentToken in the following format: | ||
* FILENAME(LINE,POSITION): TYPE(IDENT) | ||
* | ||
* @return a String representation of this IdentToken | ||
*/ | ||
@Override | ||
public String toString() { | ||
return super.toString() + String.format("(%s)", ident); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.merkrafter.lexing; | ||
|
||
/**** | ||
* This enum lists all keywords that can be encountered in JavaSST files. | ||
* | ||
* @since v0.2.0 | ||
* @author merkrafter | ||
***************************************************************/ | ||
public enum Keyword { | ||
CLASS, | ||
ELSE, | ||
FINAL, | ||
IF, | ||
INT, | ||
PUBLIC, | ||
RETURN, | ||
VOID, | ||
WHILE, | ||
} |
Oops, something went wrong.