Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
195 additions
and
1 deletion.
There are no files selected for viewing
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,76 @@ | ||
/* | ||
* expressionunit.d | ||
* | ||
* This module parses expressions. | ||
* | ||
*/ | ||
|
||
module parsing.d.gotostmtunit; | ||
|
||
import parsing.parseunit; | ||
import parsing.token; | ||
|
||
import parsing.d.tokens; | ||
import parsing.d.nodes; | ||
|
||
import parsing.d.expressionunit; | ||
|
||
import io.console; | ||
|
||
import djehuty; | ||
|
||
class GotoStmtUnit : ParseUnit { | ||
override bool tokenFound(Token current) { | ||
switch (current.type) { | ||
case DToken.Semicolon: | ||
if (this.state == 0) { | ||
// Error. | ||
// TODO: | ||
} | ||
if (this.state == 2) { | ||
// Error. | ||
// TODO: | ||
} | ||
// Done. | ||
return false; | ||
case DToken.Identifier: | ||
if (this.state != 0) { | ||
// Error | ||
// TODO: | ||
} | ||
Console.putln("Goto: ", current.value); | ||
cur_string = current.value.toString(); | ||
this.state = 1; | ||
break; | ||
case DToken.Default: | ||
Console.putln("Goto: Default"); | ||
this.state = 2; | ||
break; | ||
case DToken.Case: | ||
Console.putln("Goto: Case"); | ||
this.state = 2; | ||
break; | ||
default: | ||
if (this.state != 2) { | ||
// Error | ||
// TODO: | ||
} | ||
|
||
lexer.push(current); | ||
if (this.state == 3) { | ||
// Error: Multiple expressions | ||
// TODO: | ||
} | ||
auto tree = expand!(ExpressionUnit)(); | ||
this.state = 3; | ||
break; | ||
} | ||
return true; | ||
} | ||
|
||
protected: | ||
string cur_string = ""; | ||
|
||
static const string _common_error_msg = ""; | ||
static const string[] _common_error_usages = null; | ||
} |
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,51 @@ | ||
/* | ||
* expressionunit.d | ||
* | ||
* This module parses expressions. | ||
* | ||
*/ | ||
|
||
module parsing.d.returnstmtunit; | ||
|
||
import parsing.parseunit; | ||
import parsing.token; | ||
|
||
import parsing.d.tokens; | ||
import parsing.d.nodes; | ||
|
||
import parsing.d.expressionunit; | ||
|
||
import io.console; | ||
|
||
import djehuty; | ||
|
||
class ReturnStmtUnit : ParseUnit { | ||
override bool tokenFound(Token current) { | ||
switch (current.type) { | ||
case DToken.Semicolon: | ||
// Done. | ||
return false; | ||
|
||
default: | ||
if (this.state == 1) { | ||
// Error: Multiple expressions | ||
// TODO: | ||
} | ||
|
||
lexer.push(current); | ||
|
||
// Expression follows... and then a semicolon | ||
auto tree = expand!(ExpressionUnit)(); | ||
this.state = 1; | ||
|
||
break; | ||
} | ||
return true; | ||
} | ||
|
||
protected: | ||
string cur_string = ""; | ||
|
||
static const string _common_error_msg = ""; | ||
static const string[] _common_error_usages = null; | ||
} |
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,51 @@ | ||
/* | ||
* expressionunit.d | ||
* | ||
* This module parses expressions. | ||
* | ||
*/ | ||
|
||
module parsing.d.volatilestmtunit; | ||
|
||
import parsing.parseunit; | ||
import parsing.token; | ||
|
||
import parsing.d.tokens; | ||
import parsing.d.nodes; | ||
|
||
import parsing.d.statementunit; | ||
|
||
import io.console; | ||
|
||
import djehuty; | ||
|
||
class VolatileStmtUnit : ParseUnit { | ||
override bool tokenFound(Token current) { | ||
switch (current.type) { | ||
case DToken.Semicolon: | ||
// Done. | ||
return false; | ||
|
||
default: | ||
if (this.state == 1) { | ||
// Error: Multiple statements!? | ||
// TODO: | ||
} | ||
|
||
lexer.push(current); | ||
|
||
// Statement Follows. | ||
auto tree = expand!(StatementUnit)(); | ||
this.state = 1; | ||
|
||
break; | ||
} | ||
return true; | ||
} | ||
|
||
protected: | ||
string cur_string = ""; | ||
|
||
static const string _common_error_msg = ""; | ||
static const string[] _common_error_usages = null; | ||
} |
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