change blang op meanings
This commit is contained in:
		
							parent
							
								
									905a0e9056
								
							
						
					
					
						commit
						da0ec7de01
					
				
							
								
								
									
										11
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								README.md
									
									
									
									
									
								
							| @ -16,11 +16,10 @@ Public domain. 2022 DTB. | ||||
| 
 | ||||
| ## true(1) | ||||
| ``` | ||||
| ^ ; initialize state to 0 | ||||
| % ; store state (0) into *stack | ||||
| ; stack is destroyed, state becomes the final value of *stack | ||||
| ; when the stack is destroyed, the program exits with the value of state | ||||
| $ | ||||
| ^ ; initialize hand to 0 | ||||
| ; set the chart pointer to 0 - this destroys the chart | ||||
| ; and the program exits with the value of the hand | ||||
| *  | ||||
| ``` | ||||
| 
 | ||||
| ## Hello world: | ||||
| @ -28,5 +27,5 @@ $ | ||||
| ; the <.> construct uses '<' to store the next value literally into state, | ||||
| ; does so, and uses '>' to output state literally | ||||
| <H><e><l><l><o><,>< ><w><o><r><l><d><!>< | ||||
| >^%$ | ||||
| >^* | ||||
| ``` | ||||
|  | ||||
| @ -3,5 +3,5 @@ | ||||
| struct State{ | ||||
| 	unsigned char hand; | ||||
| 	char *chart; | ||||
| } | ||||
| }; | ||||
| #endif | ||||
|  | ||||
							
								
								
									
										14
									
								
								src/ops.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/ops.c
									
									
									
									
									
								
							| @ -1,5 +1,6 @@ | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| 
 | ||||
| #include "blang.h" | ||||
| 
 | ||||
| @ -17,11 +18,11 @@ void Ops_carat(struct State *s){ | ||||
| } | ||||
| 
 | ||||
| void Ops_ampersand(struct State *s){ | ||||
| 	s->hand = s->chart; | ||||
| 	s->hand = (char)s->chart; | ||||
| } | ||||
| 
 | ||||
| void Ops_splat(struct State *s){ | ||||
| 	s->chart = s->hand; | ||||
| 	s->chart = (char *)s->hand; | ||||
| } | ||||
| 
 | ||||
| void Ops_plus(struct State *s){ | ||||
| @ -41,6 +42,8 @@ void Ops_left(struct State *s){ | ||||
| } | ||||
| 
 | ||||
| void Ops_semi(struct State *s){ | ||||
| 	int c; | ||||
| 
 | ||||
| 	while( | ||||
| 		(c = getc(stdin)) != EOF | ||||
| 		&& strchr("!\n", c) == NULL | ||||
| @ -57,10 +60,9 @@ void Ops_cross(struct State *s){ | ||||
| const struct { | ||||
| 	unsigned char name; | ||||
| 	void (*f)(struct State *); | ||||
| } *OPS[] = { | ||||
| 	{ '$', Ops_dollar }, | ||||
| } OPS[] = { | ||||
| 	{ '%', Ops_percent }, | ||||
| 	{ '^', Ops_caret }, | ||||
| 	{ '^', Ops_carat }, | ||||
| 	{ '&', Ops_ampersand }, | ||||
| 	{ '*', Ops_splat }, | ||||
| 	{ '+', Ops_plus }, | ||||
| @ -80,7 +82,7 @@ const struct { | ||||
| 
 | ||||
| /* Slower than a switch but you don't have to update it when you add new
 | ||||
|  * ops! */ | ||||
| (void(struct State *)) Ops_lookup(char op){ | ||||
| void (*Ops_lookup(char op))(struct State *){ | ||||
| 	size_t i; | ||||
| 
 | ||||
| 	for(i = 0; i < (sizeof OPS)/(sizeof *OPS); ++i) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user