?~ register now takes in an argument
This commit is contained in:
parent
dacb9836a0
commit
b5b6472ebc
|
@ -1,9 +1,9 @@
|
|||
<> ((You said: quit\n) send) ((You quit.) print ')
|
||||
<> (?: print ') (?:)
|
||||
<> (?: send) (?: wait)
|
||||
<> (wait) ((You said: ?~\n) send)
|
||||
<> (?: send) (?: wait stdin)
|
||||
<> (wait ?~) ((You said: ?~\n) send)
|
||||
<> (' ?x) (?x ')
|
||||
|
||||
(Say something, or type "quit": \n) print '
|
||||
|
||||
wait
|
||||
wait stdin
|
|
@ -1,5 +1,4 @@
|
|||
<> (NAME) (Modal)
|
||||
<> (?: print $) (?:)
|
||||
<> ($ ?x) (?x $)
|
||||
|
||||
$ (Welcome to NAME \nHave fun!\n\n) print
|
||||
<> (listen ?~) (?~ done.)
|
||||
|
||||
foo listen stdin bar
|
|
@ -1,7 +1,7 @@
|
|||
-- (Tic Tac Toe)
|
||||
|
||||
<> (-- ?x) ()
|
||||
<> (READ) (?~)
|
||||
<> (READ ?~) (?~)
|
||||
|
||||
-- (Print)
|
||||
|
||||
|
@ -34,8 +34,8 @@
|
|||
|
||||
-- (Play)
|
||||
|
||||
<> (ready) (display READ play)
|
||||
<> (?x run wait) (READ play)
|
||||
<> (ready) (display READ stdin play)
|
||||
<> (?x run wait) (READ stdin play)
|
||||
<> (?x victory) ((?x wins!\n) put-str)
|
||||
|
||||
-- (Interface)
|
||||
|
|
68
src/modal.c
68
src/modal.c
|
@ -45,45 +45,41 @@ set_reg(int r, char *b)
|
|||
static void
|
||||
put_reg(char r)
|
||||
{
|
||||
char c, *s = regs[(int)r];
|
||||
if(r == '~') {
|
||||
/* special stdin */
|
||||
char c, *s = regs[(int)r], *ss;
|
||||
if(!s) {
|
||||
*outp_++ = '?', *outp_++ = r;
|
||||
return;
|
||||
}
|
||||
*ss = walk(s);
|
||||
if(r == '*') {
|
||||
if(*s == '(') { /* special implode */
|
||||
while(s < ss && (c = *s++))
|
||||
if(!spacer(c)) *outp_++ = c;
|
||||
} else { /* special explode */
|
||||
int i, depth = 0;
|
||||
while((c = *s++) && !spacer(c))
|
||||
*outp_++ = c, *outp_++ = ' ', *outp_++ = '(', depth++;
|
||||
for(i = 0; i < depth; i++)
|
||||
*outp_++ = ')';
|
||||
}
|
||||
} else if(r == ':') { /* special stdout */
|
||||
if(*s == '(') s++, --ss;
|
||||
while(s < ss) {
|
||||
c = *s++;
|
||||
if(c == '\\') {
|
||||
switch(*s++) {
|
||||
case 't': putc(0x09, stdout); break;
|
||||
case 'n': putc(0x0a, stdout); break;
|
||||
case 's': putc(0x20, stdout); break;
|
||||
}
|
||||
} else
|
||||
putc(c, stdout);
|
||||
}
|
||||
} else if(r == '~') { /* special stdin */
|
||||
while(fread(&c, 1, 1, stdin) && c >= ' ')
|
||||
*outp_++ = c;
|
||||
} else if(s) {
|
||||
char *ss = walk(s);
|
||||
if(r == '*') {
|
||||
/* special implode */
|
||||
if(*s == '(') {
|
||||
while(s < ss && (c = *s++))
|
||||
if(!spacer(c)) *outp_++ = c;
|
||||
}
|
||||
/* special explode */
|
||||
else {
|
||||
int i, depth = 0;
|
||||
while((c = *s++) && !spacer(c))
|
||||
*outp_++ = c, *outp_++ = ' ', *outp_++ = '(', depth++;
|
||||
for(i = 0; i < depth; i++)
|
||||
*outp_++ = ')';
|
||||
}
|
||||
} else if(r == ':') {
|
||||
/* special stdout */
|
||||
if(*s == '(') s++, --ss;
|
||||
while(s < ss) {
|
||||
c = *s++;
|
||||
if(c == '\\') {
|
||||
switch(*s++) {
|
||||
case 't': putc(0x09, stdout); break;
|
||||
case 'n': putc(0x0a, stdout); break;
|
||||
case 's': putc(0x20, stdout); break;
|
||||
}
|
||||
} else
|
||||
putc(c, stdout);
|
||||
}
|
||||
} else
|
||||
while(s < ss) *outp_++ = *s++;
|
||||
} else
|
||||
*outp_++ = '?', *outp_++ = r;
|
||||
while(s < ss) *outp_++ = *s++;
|
||||
}
|
||||
|
||||
static char *
|
||||
|
|
Loading…
Reference in New Issue