changeset 626:23c93af11ae8

fix interpreter example
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 09 Jun 2020 15:17:35 +0900
parents d02866506b9b
children 4fe715132abe
files src/parallel_execution/CMakeLists.txt src/parallel_execution/examples/piposaru/lexer.h src/parallel_execution/examples/piposaru/lexer_impl.cbc src/parallel_execution/examples/piposaru/main.cbc src/parallel_execution/examples/piposaru/piposaru.h src/parallel_execution/examples/piposaru/token_impl.cbc
diffstat 6 files changed, 29 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Tue Jun 09 15:01:53 2020 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Tue Jun 09 15:17:35 2020 +0900
@@ -145,6 +145,6 @@
   TARGET
      piposaru
   SOURCES
-  examples/piposaru/lexer_impl.cbc  examples/piposaru/main.cbc  examples/piposaru/token_impl.cbc
+  examples/piposaru/lexer_impl.cbc  examples/piposaru/main.cbc  examples/piposaru/token_impl.cbc TaskManagerImpl.cbc
 
 )
--- a/src/parallel_execution/examples/piposaru/lexer.h	Tue Jun 09 15:01:53 2020 +0900
+++ b/src/parallel_execution/examples/piposaru/lexer.h	Tue Jun 09 15:17:35 2020 +0900
@@ -1,6 +1,7 @@
 typedef struct lexer <Type, Impl> {
-    __code read_char(Impl* lexer, char* ch, __code next(... ));
-    __code eat_whitespace(Impl* lexer, char* ch, __code next(... ));
-    __code next_token(Impl* lexer, __code next(struct token* tok, ...));
-    __code next(....);
+  __code read_char(Impl* lexer, char* ch, __code next(... ));
+  __code eat_whitespace(Impl* lexer, char* ch, __code next(... ));
+  __code next_token(Impl* lexer, __code next(struct token* tok, ...));
+  __code printtest(Impl* lexer, __code next(...));
+  __code next(....);
 } lexer;
--- a/src/parallel_execution/examples/piposaru/lexer_impl.cbc	Tue Jun 09 15:01:53 2020 +0900
+++ b/src/parallel_execution/examples/piposaru/lexer_impl.cbc	Tue Jun 09 15:17:35 2020 +0900
@@ -1,4 +1,5 @@
 #include "../../../context.h"
+#include <stdio.h>
 #interface "lexer.h"
 
 // ----
@@ -11,23 +12,29 @@
     struct lexer* lexer  = new lexer();
     struct lexer_impl* lexer_impl = new lexer_impl();
     lexer->lexer = (union Data*)lexer_impl;
-    lexer->read_char = C_read_charlexer_impl;
-    lexer->eat_whitespace = C_eat_whitespacelexer_impl;
-    lexer->next_token = C_next_tokenlexer_impl;
+    lexer->read_char = C_read_char_lexer_impl;
+    lexer->eat_whitespace = C_eat_whitespace_lexer_impl;
+    lexer->next_token = C_next_token_lexer_impl;
+    lexer->printtest = C_printtest_lexer_impl;
     return lexer;
 }
-__code read_charlexer_impl(struct lexer_impl* lexer, char* ch, __code next(... )) {
+__code read_char_lexer_impl(lexer_impl* lexer, char* ch, __code next(... )) {
 
     goto next(... );
 }
 
-__code eat_whitespacelexer_impl(struct lexer_impl* lexer,char* ch, __code next(... )) {
+__code eat_whitespace_lexer_impl(lexer_impl* lexer, char* ch, __code next(... )) {
 
     goto next(... );
 }
 
-__code next_tokenlexer_impl(struct lexer_impl* lexer, __code next(struct token* tok, ...)) {
+__code next_token_lexer_impl(lexer_impl* lexer, __code next(token* tok, ...)) {
 
     goto next(tok, ...);
 }
 
+__code printtest_lexer_impl(lexer_impl* lexer, __code next(...)) {
+    printf("hello!!\n");
+    goto next(...);
+}
+
--- a/src/parallel_execution/examples/piposaru/main.cbc	Tue Jun 09 15:01:53 2020 +0900
+++ b/src/parallel_execution/examples/piposaru/main.cbc	Tue Jun 09 15:17:35 2020 +0900
@@ -36,24 +36,12 @@
 
 
 __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
-    lexer* lexer1 = createlexer_impl(context);
-    par goto printest(lexer1, __exit);
-    goto code2();
+    lexer* lexer = new lexer();
+    goto lexer->printtest(exit_code);
 }
 
 
-__code printest(struct lexer* lexer1, __code next(...)) {
-  printf("hello!!\n");
-  goto next(...);
-}
 
-__code code2(struct TaskManager* taskManager) {
-    goto taskManager->shutdown(exit_code);
-}
-
-__code code2_stub(struct Context* context) {
-    goto code2(context, &Gearef(context, TaskManager)->taskManager->TaskManager);
-}
 
 void init(int argc, char** argv) {
     for (int i = 1; argv[i]; ++i) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parallel_execution/examples/piposaru/piposaru.h	Tue Jun 09 15:17:35 2020 +0900
@@ -0,0 +1,5 @@
+enum TokenKind {
+  TK_RESERVED,
+  TK_NUM,
+  TK_EOF,
+};
--- a/src/parallel_execution/examples/piposaru/token_impl.cbc	Tue Jun 09 15:01:53 2020 +0900
+++ b/src/parallel_execution/examples/piposaru/token_impl.cbc	Tue Jun 09 15:17:35 2020 +0900
@@ -1,4 +1,4 @@
-#include "../context.h"
+#include "../../../context.h"
 #interface "token.h"
 
 // ----
@@ -11,10 +11,10 @@
     struct token* token  = new token();
     struct token_impl* token_impl = new token_impl();
     token->token = (union Data*)token_impl;
-    token->add = C_addtoken_impl;
+    token->add = C_add_token_impl;
     return token;
 }
-__code addtoken_impl(struct token_impl* token, enum DataType tk, char* datum, __code next(...)) {
+__code add_token_impl(struct token_impl* token, enum TokenKind tk, char* datum, __code next(...)) {
 
     goto next(...);
 }