• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

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

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

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


コミットメタ情報

リビジョン23 (tree)
日時2018-09-28 08:46:31
作者bellyoshi

ログメッセージ

変更サマリ

差分

--- trunk/csmock/WindowsFormsApp1/getToken/Token.cs (revision 22)
+++ trunk/csmock/WindowsFormsApp1/getToken/Token.cs (revision 23)
@@ -30,7 +30,7 @@
3030 public string src_str { get; }
3131 public bool isEof()
3232 {
33- return src_str == ";";//"とりあえずセミコロンで終わる。
33+ return TokenType == TokenType.EndOfFile;
3434 }
3535 public Token(string src_str ,int src_line, int src_col, TokenType t)
3636 {
--- trunk/csmock/WindowsFormsApp1/getToken/TokenGetter.cs (revision 22)
+++ trunk/csmock/WindowsFormsApp1/getToken/TokenGetter.cs (revision 23)
@@ -43,10 +43,14 @@
4343 }
4444 TokenType getCharType(int c)
4545 {
46+ if(c == -1)
47+ {
48+ return EndOfFile;
49+ }
4650 char chr = (char)c;
47- if (chr >= '0' && chr <= '9')
51+ if ('0' <= chr && chr <= '9')
4852 return Digit;
49- if ((chr >= 'A' && chr <= 'Z') || (chr >= 'a' && chr <= 'z'))
53+ if (('A' <= chr && chr <= 'Z') || ('a' <= chr && chr <= 'z'))
5054 return Letter;
5155
5256 switch (chr)
@@ -65,7 +69,7 @@
6569 case ',': return Comma;
6670 case '.': return Period;
6771 case '"': return DoubleQuote;
68- case ';': return EndOfFile;//test用 Semicolon;
72+ //test用 Semicolon;
6973 case '\n': return EndOfLine;
7074 case ':': return Colon;
7175 default:
@@ -82,6 +86,7 @@
8286
8387 add_char_to_src_str(curChar);
8488 curChar = Console.Read();
89+
8590 if (curChar == '\n')
8691 {
8792
--- trunk/csmock/WindowsFormsApp1/getToken/compile.cs (revision 22)
+++ trunk/csmock/WindowsFormsApp1/getToken/compile.cs (revision 23)
@@ -120,13 +120,13 @@
120120 {
121121 next();
122122 Console.Write(",");
123- expression();//color
123+ if(nextToken.TokenType != TokenType.Comma) {
124+ expression();//color
125+ }
124126 }
125127 else
126128 {
127- next();
128- Console.WriteLine(")");
129- return;
129+ goto line_end;
130130 }
131131 if (nextToken.TokenType == TokenType.Comma)
132132 {
@@ -135,9 +135,7 @@
135135 }
136136 else
137137 {
138- next();
139- Console.WriteLine(")");
140- return;
138+ goto line_end;
141139 }
142140 if (nextToken.TokenType == TokenType.identifier
143141 && (nextToken.src_str == "B" || nextToken.src_str == "BF"))
@@ -149,8 +147,10 @@
149147 if (nextToken.TokenType == TokenType.Comma)
150148 {
151149 Console.Write(",");
150+ next();
152151 expression();//color2
153152 }
153+ line_end:
154154 Console.WriteLine(")");
155155 next();
156156 }