1
0

パーサーのバグ修正,Comiplerを定義

This commit is contained in:
otya128
2015-06-04 20:51:03 +09:00
parent 2a4db7d6a5
commit de5db9282c
4 changed files with 34 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ module otya.smilebasic.parser;
import otya.smilebasic.token;
import otya.smilebasic.type;
import otya.smilebasic.node;
import otya.smilebasic.compiler;
import std.ascii;
import std.stdio;
class Lexical
@@ -97,6 +98,7 @@ class Lexical
if(r != TokenType.Unknown)
{
token = Token(r);
break;
}
}
token = Token(TokenType.Iden, Value(iden));
@@ -260,6 +262,8 @@ class Parser
}
void compile()
{
auto compiler = new Compiler(parseProgram());
compiler.compile();
}
Statements parseProgram()
{
@@ -278,7 +282,7 @@ class Parser
}
void syntaxError()
{
stderr.writeln("Syntax error", lex.getLine());
stderr.writeln("Syntax error (", lex.getLine(), ')');
}
//statement
Statement statement()
@@ -322,13 +326,14 @@ class Parser
print.addArgument(exp);
lex.popFront();
token = lex.front();
if(lex.empty()) break;
if(token.type != TokenType.Colon && token.type != TokenType.NewLine && token.type != TokenType.Semicolon && token.type != TokenType.Comma)
{
syntaxError();
}
}
return print;
}
break;
case TokenType.Colon:
case TokenType.NewLine:
break;