ヘッダーファイルの整理
[YACASL2.git] / include / assemble.h
index 257fe37..3ab7a86 100644 (file)
@@ -1,25 +1,16 @@
-#ifndef YACASL2_ASSEMBLE_INCLUDED
-#define YACASL2_ASSEMBLE_INCLUDED
+#ifndef YACASL2_ASSEMBLE_H_INCLUDED
+#define YACASL2_ASSEMBLE_H_INCLUDED
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <stdbool.h>
+#include <ctype.h>
+#include <assert.h>
+#include <errno.h>
+#include "cerr.h"
 #include "struct.h"
-#include "word.h"
-
-/**
- * @brief CASL IIの仕様
- */
-enum {
-    LABELSIZE = 8,         /**<ラベルの最大文字数 */
-    OPDSIZE = 40,          /**<オペラントの最大数。CASL IIシミュレータの制限 */
-};
-
-/**
- * @brief YACASL2の制限
- */
-enum {
-    LINESIZE = 1024,       /**<行の最大文字数 */
-    TOKENSIZE = 256,       /**<トークンの最大文字数 */
-};
+#include "token.h"
 
 /**
  * @brief アセンブルモードを表すデータ型
@@ -65,9 +56,7 @@ typedef struct {
  */
 typedef struct _LABELTAB {
     struct _LABELTAB *next;     /**<リスト次項目へのポインタ */
-    char *prog;                 /**<プログラム名  */
-    char *label;                /**<ラベル名 */
-    WORD adr;                   /**<アドレス */
+    LABELARRAY *label;          /**<ラベル配列 */
 } LABELTAB;
 
 /**
@@ -127,39 +116,6 @@ void printlabel();
  */
 void freelabel();
 
-/**
- * @brief オペランドを表すデータ型
- */
-typedef struct {
-    int opdc;                   /**<オペランド数 */
-    char *opdv[OPDSIZE];        /**<オペランド配列 */
-} OPD;
-
-/**
- * @brief 命令行を表すデータ型
- */
-typedef struct {
-    char *label;                /**<ラベル */
-    char *cmd;                  /**<コマンド */
-    OPD *opd;                   /**<オペランド */
-} CMDLINE;
-
-/**
- * @brief トークン取得のエラーを追加する
- *
- * @return なし
- */
-void addcerrlist_tok();
-
-/**
- * @brief 行から、ラベル・コマンド・オペランドを取得する
- *
- * @return ラベル・コマンド・オペランド
- *
- * @param *line 行
- */
-CMDLINE *linetok(const char *line);
-
 /**
  * @brief アセンブルエラーをエラーリストに追加する
  *
@@ -179,6 +135,17 @@ void addcerrlist_assemble();
  */
 bool assemblefile(const char *file, PASS pass);
 
+/**
+ * @brief 指定された1つまたは複数のファイルを2回アセンブル
+ *
+ * @return アセンブル完了時はtrue、エラー発生時はfalseを返す
+ *
+ * @param filec アセンブルするファイルの数
+ * @param filev アセンブルするファイル名の配列
+ * @param adr アセンブル結果を格納するアドレス
+ */
+bool assemble(int filec, char *filev[], WORD adr);
+
 /**
  * @brief ファイルにアセンブル結果を書き込む
  *
@@ -188,4 +155,4 @@ bool assemblefile(const char *file, PASS pass);
  */
 void outassemble(const char *file);
 
-#endif            /* YACASL2_ASSEMBLE_INCLUDEDの終端 */
+#endif