• R/O
  • SSH
  • HTTPS

jpl: Commit


Commit MetaInfo

Revision483 (tree)
Time2019-03-10 07:59:15
Authorjakobthomsen

Log Message

use oninput construct

Change Summary

Incremental Difference

--- trunk/experimental2/compiler.compiled.c (revision 482)
+++ trunk/experimental2/compiler.compiled.c (revision 483)
@@ -799,22 +799,11 @@
799799
800800 break;
801801 }
802- case /*main*/1835100526LLU:
802+ case /*onchar*/122519904870770LLU:
803803 {
804-/*intro*/memory[tuple2_access0(stackframe)].value = 18446744073709551615LLU;
805- stack_push(&callstack, stackframe);
806- stackframe = tuple2_alloc(452824691311LLU, 0);
807- result = 0;
808- break;
809- }
810- case 18446744073709551615LLU:
811- {
812- result = stack_pop(&callstack);
813804
814- uint32_t c = (uint32_t)getchar();
805+ uint32_t c = (uint32_t)memory[tuple2_access1(stackframe)].value;
815806
816- while((uint32_t)c <= 255)
817- {
818807 while(isspace(c)) c = (uint32_t)getchar(); // skip WS
819808 if((unsigned int)c > 255)
820809 {
@@ -975,16 +964,46 @@
975964 printf(" }\n");
976965
977966 c = (uint32_t)getchar();
967+ tuple2_free(stackframe);
968+ stackframe = stack_pop(&callstack);
969+ stack_push(&callstack, result);
970+
971+ break;
972+ }
973+ case /*main*/1835100526LLU:
974+ {
975+/*intro*/memory[tuple2_access0(stackframe)].value = 18446744073709551615LLU;
976+ stack_push(&callstack, stackframe);
977+ stackframe = tuple2_alloc(452824691311LLU, 0);
978+ result = 0;
979+ break;
980+ }
981+ case 18446744073709551615LLU:
982+ {
983+ result = stack_pop(&callstack);
984+/*oninput*/
985+ stack_push(&callstack, 0);
986+ memory[tuple2_access0(stackframe)].value = 18446744073709551614LLU;
987+ break;
988+ }
989+ case 18446744073709551614LLU:
990+ {
991+ /*unit*/(void)stack_pop(&callstack);
992+ if((unsigned int)ungetc(getchar(), stdin) <= 255)
993+ {/*onchar*/
994+ memory[tuple2_access0(stackframe)].value = 18446744073709551614LLU;
995+ stack_push(&callstack, stackframe);
996+ stackframe = tuple2_alloc(122519904870770LLU, (uint64_t)getchar());
997+ result = 0;
998+ break;
978999 }
979-
980- memory[tuple2_access0(stackframe)].value = 0;
981- /*outro*/memory[tuple2_access0(stackframe)].value = 18446744073709551614LLU;
1000+/*outro*/memory[tuple2_access0(stackframe)].value = 18446744073709551613LLU;
9821001 stack_push(&callstack, stackframe);
9831002 stackframe = tuple2_alloc(478711935599LLU, 0);
9841003 result = 0;
9851004 break;
9861005 }
987- case 18446744073709551614LLU:
1006+ case 18446744073709551613LLU:
9881007 {
9891008 result = stack_pop(&callstack);
9901009 result = 0;
--- trunk/experimental2/compiler.source.c (revision 482)
+++ trunk/experimental2/compiler.source.c (revision 483)
@@ -417,14 +417,11 @@
417417 `
418418 }
419419
420-main
420+onchar
421421 {
422- intro
423422 `
424- uint32_t c = (uint32_t)getchar();
423+ uint32_t c = (uint32_t)memory[tuple2_access1(stackframe)].value;
425424
426- while((uint32_t)c <= 255)
427- {
428425 while(isspace(c)) c = (uint32_t)getchar(); // skip WS
429426 if((unsigned int)c > 255)
430427 {
@@ -585,10 +582,15 @@
585582 printf(" }\n");
586583
587584 c = (uint32_t)getchar();
588- }
585+ `
586+}
589587
590- memory[tuple2_access0(stackframe)].value = 0;
591- `
588+main
589+{
590+ intro
591+
592+ oninput onchar
593+
592594 outro
593595
594596 @ 0
Show on old repository browser