• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubybathyscaphegamephpguicwindows翻訳pythonomegattwitterframeworkbtronarduinovb.net計画中(planning stage)directxpreviewertestゲームエンジンdom

N88BASICが簡単に動くインタープリタを目指します。


コミットメタ情報

リビジョン24 (tree)
日時2018-09-30 14:51:43
作者bellyoshi

ログメッセージ

変更サマリ

差分

--- trunk/csmock/WindowsFormsApp1/getToken/TokenGetter.cs (revision 23)
+++ trunk/csmock/WindowsFormsApp1/getToken/TokenGetter.cs (revision 24)
@@ -28,6 +28,10 @@
2828 rKWD("step", ab_step);
2929 rKWD("print", abn88_print);
3030 rKWD("line", abn88_line);
31+
32+ }
33+ public void Init()
34+ {
3135 curChar = Console.Read();
3236 }
3337 /// <summary>
@@ -69,7 +73,7 @@
6973 case ',': return Comma;
7074 case '.': return Period;
7175 case '"': return DoubleQuote;
72- //test用 Semicolon;
76+ case '\r':return EndOfLine;
7377 case '\n': return EndOfLine;
7478 case ':': return Colon;
7579 default:
@@ -83,8 +87,9 @@
8387 int curChar = 0;
8488 void NextChar()
8589 {
90+ if (curChar == -1) return;
91+ add_char_to_src_str(curChar);
8692
87- add_char_to_src_str(curChar);
8893 curChar = Console.Read();
8994
9095 if (curChar == '\n')
@@ -102,7 +107,7 @@
102107
103108 public TokenType NextTokenType()
104109 {
105- while (curChar == ' ' || curChar == '\t' || curChar == '\r')
110+ while (curChar == ' ' || curChar == '\t')// || curChar == '\r')
106111 {
107112 NextChar();
108113 }
--- trunk/csmock/WindowsFormsApp1/getToken/compile.cs (revision 23)
+++ trunk/csmock/WindowsFormsApp1/getToken/compile.cs (revision 24)
@@ -20,6 +20,7 @@
2020 /// <returns>true:コンパイル成功</returns>
2121 public bool DoComple(){
2222 Console.WriteLine("start compile");
23+ tg.Init();
2324 next();
2425 while (! nextToken.isEof() )
2526 {
@@ -33,7 +34,6 @@
3334 switch (nextToken.TokenType)
3435 {
3536 case TokenType.abn88_line:
36- next();
3737 s_abn88_Line();
3838 break;
3939 case TokenType.abn88_print:
@@ -40,11 +40,16 @@
4040 next();
4141 s_abn88_Print();
4242 break;
43+ case TokenType.EndOfLine:
44+ next();
45+ break;
46+
4347 }
4448 }
4549
4650 public void s_abn88_Line()
4751 {
52+ next();
4853 Console.Write("n88.Line(");
4954 if (nextToken.TokenType == TokenType.Lparen)
5055 {
@@ -122,6 +127,7 @@
122127 Console.Write(",");
123128 if(nextToken.TokenType != TokenType.Comma) {
124129 expression();//color
130+ next();
125131 }
126132 }
127133 else
@@ -149,10 +155,11 @@
149155 Console.Write(",");
150156 next();
151157 expression();//color2
158+ next();
152159 }
153160 line_end:
154161 Console.WriteLine(")");
155- next();
162+
156163 }
157164 void expression()
158165 {
@@ -207,7 +214,7 @@
207214 }
208215 next();
209216 factor();
210-
217+ t = nextToken.TokenType;
211218 }
212219 }
213220 void factor()
@@ -217,17 +224,15 @@
217224 Console.Write(nextToken.src_str);
218225 next();
219226 }
220- if (nextToken.TokenType == TokenType.int_value)
227+ else if (nextToken.TokenType == TokenType.int_value)
221228 {
222229 Console.Write(nextToken.src_str);
223230 next();
224- }
225- if (nextToken.TokenType == TokenType.double_value)
231+ }else if (nextToken.TokenType == TokenType.double_value)
226232 {
227233 Console.Write(nextToken.src_str);
228234 next();
229- }
230- if(nextToken.TokenType == TokenType.Lparen)
235+ }else if(nextToken.TokenType == TokenType.Lparen)
231236 {
232237 next();
233238 expression();