#include <stdio.h>
#include <string.h>
+#define FILENAME_MAX 256
/*** toplev.c ***/
int toplev_main(int argc, const char** argv);
-/*** toplev_cpp.cpp ***/
+/*** expression.c ***/
+
+struct Expression
+{
+ int aa;
+};
+
+struct Expression* alloc_expression();
+
+
+/*** stream.c ***/
+
+#define STREAM_FILE 1
+
+struct StreamInfo
+{
+ int type;
+ union
+ {
+ struct
+ {
+ char filename[FILENAME_MAX];
+ FILE *fp;
+ }file;
+ };
+};
+
+struct StreamInfo open_stream_file(char fname[FILENAME_MAX]);
+void close_stream(struct StreamInfo info);
+char stream_nextchar(struct StreamInfo info);
+
+/*** token.c ***/
+
+#define NULL_TOKEN (struct Token *)0
+
+struct LexInfo
+{
+ struct StreamInfo *stream;
+ char n;
+};
+
+struct Token
+{
+
+};
+
+
/* disable object mangling */
+/* using this when calling C++ functions */
+/*
#ifdef __cplusplus
extern "C" int toplev_main_cpp(int argc, const char** argv);
#else
extern int toplev_main_cpp(int argc, const char** argv);
#endif
+*/
--- /dev/null
+#include "common.h"
+
+/*
+* expression.c --manage expressions
+*
+* Copyright(C) 2013(Heisei 25) ttwilb All rights reserved.
+*
+* This source code is released on the BSD licensing.
+*
+*/
+
+#define EXPRESSION_BUF_MAX 100
+
+struct Expression expression_buf[EXPRESSION_BUF_MAX];
+int expression_buf_count = 0;
+
+struct Expression* alloc_expression()
+{
+ if(!expression_buf_count >= EXPRESSION_BUF_MAX)
+ {
+ return &expression_buf[expression_buf_count++];
+ }else
+ {
+ printf("----Fatal: expression allocation error");
+ return (struct Expression *) 0;
+ }
+}
--- /dev/null
+#include "common.h"
+
+/*
+* stream.c --manage stream
+*
+* Copyright(C) 2013(Heisei 25) ttwilb All rights reserved.
+*
+* This source code is released on the BSD licensing.
+*
+*/
+
+struct StreamInfo open_stream_file(char fname[FILENAME_MAX])
+{
+ struct StreamInfo res;
+ strcpy(res.file.filename, fname);
+ res.file.fp = fopen(fname, "r");
+ res.type = STREAM_FILE;
+ return res;
+}
+
+void close_stream(struct StreamInfo info)
+{
+ if(info.type == STREAM_FILE)
+ fclose(info.file.fp);
+}
+
+char stream_nextchar(struct StreamInfo info)
+{
+ if(info.type == STREAM_FILE)
+ return (getc(info.file.fp));
+}
--- /dev/null
+#
+# testfile.txt --glent fource code
+#
+# Copyright(C) 2013(Heisei 25) ttwilb All rights reserved.
+#
+# This source code is released on the BSD licensing.
+#
+#
+
+
+
+3 + 2
\ No newline at end of file
--- /dev/null
+#include "common.h"
+
+/*
+* token.c --glent tokenizer
+*
+* Copyright(C) 2013(Heisei 25) ttwilb All rights reserved.
+*
+* This source code is released on the BSD licensing.
+*
+*/
+
+#define BLANK_CH " \n\r\t\f\v"
+#define NEWLINE_CH "\n"
+
+struct LexInfo open_lex(struct StreamInfo *st)
+{
+ struct LexInfo res;
+ res.stream = st;
+ res.n = stream_nextchar(*st);
+}
+
+void close_lex(struct StreamInfo *st)
+{
+ close_stream(*st);
+}
+
+bool pass_blank(struct LexInfo *le)
+{
+ bool is_in_onelinecomment = false;
+ for(;;)
+ {
+ if(le->n == (char)0) return true;
+ if(is_in_onelinecomment)
+ {
+ if(strstr(NEWLINE_CH, &le->n) != NULL)
+ {
+ is_in_onelinecomment = false;
+ }
+ }
+ else if(strstr(BLANK_CH, &le->n) != NULL)
+ {
+ if(le->n == '#') is_in_onelinecomment = true;
+ }
+ else
+ {
+ break;
+ }
+ le->n = stream_nextchar(*le->stream);
+ }
+ return false;
+}
+
+struct Token* next_token(struct LexInfo *le)
+{
+
+}
+
+
+
+
+
+
+
*
*/
+int compile_file(const char *fname)
+{
+ return 0;
+}
+
int toplev_main(int argc, const char** argv)
{
- return
- toplev_main_cpp(argc, (const char **) argv);
+ int i;
+
+ for(i = 1; i < argc; i++)
+ {
+ printf("Compiling %s ...\n", argv[i]);
+ compile_file(argv[i]);
+ }
+
+ getchar();
+ return 0;
}
+
+