Lhogho  0.0.028
 All Data Structures Files Functions Variables Typedefs Macros Pages
lhogho.c File Reference

Go to the source code of this file.

Functions

void use_stdout (chars_t string, int len)
 prints text to standard output More...
 
int use_stdeof ()
 returns eof status of standard output More...
 
char_t use_stdin ()
 reads a character More...
 
int main (int argc, char *argv[])
 

Function Documentation

void use_stdout ( chars_t  string,
int  len 
)
Parameters
stringtext to print
lenlength of text

This is a call-back outter function for dumping atom contents to standard output.

Definition at line 61 of file lhogho.c.

62 {
63  if( len==-1 ) len = STRLEN( string );
64  //printf("len=%d\n",len);
65  for( ; len>0; len--, string++ )
66  {
67  //printf("|%x|",*string);
68 
69  // ignore 0x0D (^M,CR) if not followed by 0x0A (^J,LF)
70  int crlf = (DEBAR(*string)==0x0D) && (DEBAR(*(string+1))==0x0A);
71 
72  if( !crlf )
73  {
74  char_t wc[2];
75  wc[0] = DEBAR(*string);
76  wc[1] = 0;
77 
78  char* buf =(char*) UTF16_to_UTF8(wc);
79  printf("%s",buf);
80  //printf(" %x-",*string);
81  /*
82  switch ( strlen(buf) )
83  {
84  case 1: printf("%c",(char)buf[0]); break;
85  case 2: printf("%c%c",(unsigned char)buf[0],(unsigned char)buf[1],(char)buf[0],(char)buf[1]); break;
86  case 3: printf("%c%c%c",(char)buf[0],(char)buf[1],(char)buf[2]); break;
87  case 4: printf("%c%c%c%c",(char)buf[0],(char)buf[1],(char)buf[2],(char)buf[3]); break;
88  case 5: printf("%c%c%c%c%c",(char)buf[0],(char)buf[1],(char)buf[2],(char)buf[3],(char)buf[4]); break;
89  case 6: printf("%c%c%c%c%c%c",(char)buf[0],(char)buf[1],(char)buf[2],(char)buf[3],(char)buf[4],(char)buf[5]); break;
90  }
91  */
92  DEALLOC( buf );
93  //printf( "%S", wc );
94  }
95  // PUTCHAR( DEBAR(*string), stdout );
96  //if( *string!=DEBAR(*string) )
97  //PUTCHAR( TEXT('?'), stdout );
98  }
99 }
void use_stdeof ( )

This is a call-back inner_eof function for checking standard input.

Definition at line 109 of file lhogho.c.

110 {
111  return feof(stdin)?1:0;
112 }
char_t use_stdin ( )

reads a character from standard input

Read a character from the hooked of file stream, which must be ASCII.

This is a call-back inner function for geting urser input.

Definition at line 122 of file lhogho.c.

123 {
124  char_t ch;
125  ch = GETCHAR( stdin );
126  while( ch=='\r' ) ch = GETCHAR( stdin ); // remove ^M from input, keep ^J
127  return ch;
128 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 132 of file lhogho.c.

133 {
134  int result;
135 
136  //fwide(stdout,1);
137  setvbuf( stdin, NULL, _IONBF, 0 );
138 
139  #ifdef WINDOWS
140  // Try to change the code page to UTF-8
141  //if( system("chcp 65001 >nul")!=0 )
142  //{
143  // system("chcp.com 65001 >nul");
144  //}
145  /*
146  int i;
147  printf("\n\npage c3: ");
148  for( i=0x80; i<0xbf; i++ ) printf("%c%c",(char)0xc3,(char)i);
149  printf("\n manual:");
150  printf("%c%c",(char)0xc3,(char)0x9c);
151  printf("%c%c",(char)0xc3,(char)0xbc);
152  printf("%c%c",(char)0xc3,(char)0xa4);
153  printf("%c%c",(char)0xc3,(char)0x9f);
154  */
155  #endif
156 
157  //printf("1. initialization\n");
159  //__asm__ volatile ("int $3");
160  //printf("2. options\n");
161 
162  set_options( argc, argv );
163  //printf("3. compile\n");
164  result = compile_from_options( );
165 
166  if( !result &&
169  IS_NOT_EMPTY(BODY(root)) )
170  {
171  //printf("4. run\n");
172  result = run_function( root );
173  }
174 
175  //printf("5. finalization\n");
176  finit_compiler( );
177  #ifdef WINDOWS
178  // Try to change the code page to UTF-8
179 // if( system("chcp 850 >nul")!=0 )
180 // {
181 // system("chcp.com 850 >nul");
182 // }
183  //int i;
184  //printf("\n\npage c3: ");
185  //for( i=0x80; i<0xbf; i++ ) printf("%c%c",(char)0xc3,(char)i);
186  //printf("\n manual:");
187  //printf("%c%c",(char)0xc3,(char)0x9c);
188  //printf("%c%c",(char)0xc3,(char)0xbc);
189  //printf("%c%c",(char)0xc3,(char)0xa4);
190  //printf("%c%c",(char)0xc3,(char)0x9f);
191  #endif
192 
193  //printf("6. end\n");
194  //printf("\n\n");
195  //printf("%c%c",(char)0xc3,(char)0x9c);
196  //printf("%c%c",(char)0xc3,(char)0xbc);
197  //printf("%c%c",(char)0xc3,(char)0xa4);
198  //printf("%c%c",(char)0xc3,(char)0x9f);
199 
200  //printf("\n\npage c3: ");
201  //for( i=0x80; i<0xbf; i++ ) printf("%c%c",(char)0xc3,(char)i);
202  //printf("\n manual:");
203  //printf("%c%c",(char)0xc3,(char)0x9c);
204  //printf("%c%c",(char)0xc3,(char)0xbc);
205  //printf("%c%c",(char)0xc3,(char)0xa4);
206  //printf("%c%c",(char)0xc3,(char)0x9f);
207  return result;
208 }

[ HOME | INDEX | ATOMS | VARS | REFERENCE ]
Lhogho Developer's Documentation
Wed Jul 10 2013