Permalink
Browse files

flexのメッセージ出力部を変更

Signed-off-by: Sakujyo Wakuotsu <tomo3u3u@gmail.com>
  • Loading branch information...
1 parent f83b5b6 commit c8bc19981b962b711220c1bcde645dd76e186099 @sakujyo committed Dec 9, 2011
Showing with 44 additions and 29 deletions.
  1. +44 −29 ToyASM80/ToyASM80.l
  2. BIN ToyASM80/ToyASM80.tab.exe
View
@@ -16,24 +16,23 @@
#include "ToyASM80.tab.h"
extern YYSTYPE yylval;
+#include <stdarg.h>
+void pmsg(const char *format, ...);
+
%}
/* �}�N��; ���K�\�� */
delim [ \t]
whitesp {delim}+
-
-/*
-BINPREFIX b
-*/
-
DIGIT [0-9]
INTEGER {DIGIT}+
- //HP 0x
HEXINT 0x{DIGIT}+
-LABEL [a-zA-Z][0-9a-zA-Z]+
+
+LABEL [a-zA-Z][0-9a-zA-Z]+
/* ���̂Ƃ��뒷������Ȃ� */
+
LABELDEFINITION {LABEL}:
/* �����flex�ɓ�̓t�@�C������‚ł��邱�Ƃ��. */
@@ -48,85 +47,85 @@ LABELDEFINITION {LABEL}:
*/
"A" {
- printf("Saw an register %s\n", yytext);
+ pmsg("Saw an register %s\n", yytext);
yylval = 7;
return REGA;
}
"B" {
- printf("Saw an register %s\n", yytext);
+ pmsg("Saw an register %s\n", yytext);
yylval = 0;
return REGB;
}
"C" {
- printf("Saw an register %s\n", yytext);
+ pmsg("Saw an register %s\n", yytext);
yylval = 1;
return REGC;
}
"D" {
- printf("Saw an register %s\n", yytext);
+ pmsg("Saw an register %s\n", yytext);
yylval = 2;
return REGD;
}
"E" {
- printf("Saw an register %s\n", yytext);
+ pmsg("Saw an register %s\n", yytext);
yylval = 3;
return REGE;
}
"H" {
- printf("Saw an register %s\n", yytext);
+ pmsg("Saw an register %s\n", yytext);
yylval = 4;
return REGH;
}
"L" {
- printf("Saw an register %s\n", yytext);
+ pmsg("Saw an register %s\n", yytext);
yylval = 5;
return REGL;
}
+"(HL)" {
+ pmsg("Saw an register %s\n", yytext);
+ yylval = 6;
+ return HLADDR;
+ }
+
"LD" {
- printf("Saw an mnemonic LD \n");
+ pmsg("Saw an mnemonic LD \n");
return LD;
}
"INC" {
- printf("Saw an mnemonic INC \n");
+ pmsg("Saw an mnemonic INC \n");
return INC;
}
"JP" {
- printf("Saw an mnemonic JP \n");
+ pmsg("Saw an mnemonic JP \n");
return JP;
}
-"(HL)" {
- printf("Saw an mnemonic REG8 \n");
- yylval = 6;
- return HLADDR;
- }
-
/*"x" {
printf("Saw an hexadecimal prefex: \n");
}
*/
{LABEL} {
- printf("Saw an label: %s\n", yytext);
+ pmsg("Saw an label: %s\n", yytext);
return LABEL;
}
{LABELDEFINITION} {
- printf("Saw an label definition: %s\n", yytext);
+ pmsg("Saw an label definition: %s\n", yytext);
return LABELDEFINITION;
}
{HEXINT} {
- printf("Saw an hex integer: %s\n", yytext);
+ pmsg("Saw an hex integer: %s\n", yytext);
sscanf(yytext, "%x", &yylval);
return HEXINT;
}
@@ -136,14 +135,30 @@ LABELDEFINITION {LABEL}:
* ���̋K���͓�͂��琮����\������.
* yytext�ɂ͈�v���������񂪊܂܂��.
*/
- printf("Saw an integer: %s\n", yytext);
+ pmsg("Saw an integer: %s\n", yytext);
sscanf(yytext, "%d", &yylval);
return INTEGER;
}
-{whitesp} { /* No action and no return */}
+{whitesp} {
+ /* No action and no return */
+ }
-. { return yytext[0]; /*����ȊO��̂܂ܕԂ��Ă݂� */ /* ����ȊO�̕����͖���. */ }
+. {
+ return yytext[0]; /*����ȊO��̂܂ܕԂ��Ă݂� */
+ /* ����ȊO�̕����͖���. */
+ }
%%
/*** C�R�[�h�̈� ***/
+void pmsg(const char *format, ...)
+{
+ /* #ifdef DEBUG */
+ va_list argp;
+
+ va_start(argp, format);
+ //vfprintf(stderr, format, argp);
+
+ /* #endif */
+ //printf(format, msg);
+}
View
Binary file not shown.

0 comments on commit c8bc199

Please sign in to comment.