From e8b475a846a6c819b5f7b4afbca67aa072294349 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Sat, 16 Feb 2019 00:15:07 +0900 Subject: [PATCH] =?utf8?q?assemble.h=E3=81=A8token.h=E3=82=92=E5=88=86?= =?utf8?q?=E5=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- include/assemble.h | 50 +------------------------------- include/monitor.h | 1 + include/token.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 49 deletions(-) create mode 100644 include/token.h diff --git a/include/assemble.h b/include/assemble.h index 78f5b8a..f8faf81 100644 --- a/include/assemble.h +++ b/include/assemble.h @@ -14,22 +14,7 @@ #include "hash.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 アセンブルモードを表すデータ型 @@ -135,39 +120,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 アセンブルエラーをエラーリストに追加する * diff --git a/include/monitor.h b/include/monitor.h index b2f648e..566230e 100644 --- a/include/monitor.h +++ b/include/monitor.h @@ -4,6 +4,7 @@ #include #include #include +#include "token.h" #include "assemble.h" #include "hash.h" #include "cmem.h" diff --git a/include/token.h b/include/token.h new file mode 100644 index 0000000..32b1fd7 --- /dev/null +++ b/include/token.h @@ -0,0 +1,72 @@ +#ifndef TOKEN_INCLUDE +#define TOKEN_INCLUDE + +#include +#include +#include +#include +#include +#include +#include +#include "cerr.h" +#include "cmem.h" + +/** + * @brief CASL IIの仕様 + */ +enum { + LABELSIZE = 8, /**<ラベルの最大文字数 */ + OPDSIZE = 40, /**<オペラントの最大数。CASL IIシミュレータの制限 */ +}; + +/** + * @brief YACASL2の制限 + */ +enum { + LINESIZE = 1024, /**<行の最大文字数 */ + TOKENSIZE = 256, /**<トークンの最大文字数 */ +}; + +/** + * @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 文字列から「'」以降の文字列をCASL IIのコメントとして削除する。「''」の場合は除く + * + * @return コメントを削除した文字列 + * + * @param s 文字列 + */ +char *strip_casl2_comment(char *s); + +/** + * @brief 行から、ラベル・コマンド・オペランドを取得する + * + * @return ラベル・コマンド・オペランド + * + * @param *line 行 + */ +CMDLINE *linetok(const char *line); + +#endif /* end of TOKEN_INCLUDE */ -- 2.18.0