Project Coco/R sepatutnya project yang sgt portable kerana kodnya langsung tak target untuk specific platform. Akan tetapi beberapa hari lepas, saya telah cuba untuk compile Coco/R dari source code menggunakan gcc versi 4.6.1 (pakej compiler mingw) dan ia berakhir dengan error (gcc invoked dengan gcc -c -w crp.c)
Saya cuba untuk compile COLLECT.C, CR.C, CRA.C, CRF.C, CRP.C, CRS.C, CRT.C, CRX.C dan SET.C, dan saya dapati satu-satunya kod yang bermasaalah adalah CRP.C. Saya mati akal untuk membetulkan source code ini. Sebab crp.c adalah kod C yang sempurna di Linux Mint 12. Akhirnya saya mengambil keputusan untuk compile crp.c dengan menggunakan Tiny C Compiler. Invoked tcc -c crp.c dan tcc memberikan error ini:
Buntu mencari penyelesaian, saya cuba pula mencari consultation melalui IRC di server IRC Linux Mint. Di server berkenaan ada satu channel bernama "#mingw" dan ia rupanya satu channel unofficial bagi project MingW. Saya cuba menanyakan soal ini di channel berkenaan dan beberapa orang tampil untuk membantu. Ada juga yang menanyakan tentang Coco/R sendiri, kerana ia satu project yang tidak famous berbanding project lain. Coco/R adalah satu program untuk menghasilkan compiler lain. Ia seperti tool lex dan yacc bersama dalam satu pakej. Malang sekali, tak ada penyelesaian dapat dicapai dalam sesi consultation tersebut. Cuma saya dinasihatkan untuk examine kod crp.c tersebut dalam bentuk yang dah di preprocessed. Saya invoke lagi gcc -E -o crp-pre.c crp.c untuk mendapatkan output crp.c yang dah di preprocessed. Ini adalah crp-pre.c:
Alhamdulillah! :) Terima kasih kerana sudi membaca. Selamat berprogramming!
Error ini memanglah tak sepatutnya keluar. Dan memang error ini langsung tak keluar bila saya compile kod yang sama di Linux Mint 12 (juga menggunakan gcc versi 4.6.1). Ia tercompile dengan sempurna tanpa apa-apa warning di Linux Mint 12. Nasib baik saya invoke gcc diatas dengan -w, kalau tak, console saya dah penuh dengan warning.crp.h:168:6: error: conflicting types for 'SynError'
crp.h:27:6: note: previous declaration of 'SynError' was here
crp.h:178:6: error: conflicting types for 'SemError'
crp.h:30:6: note: previous declaration of 'SemError' was here
Saya cuba untuk compile COLLECT.C, CR.C, CRA.C, CRF.C, CRP.C, CRS.C, CRT.C, CRX.C dan SET.C, dan saya dapati satu-satunya kod yang bermasaalah adalah CRP.C. Saya mati akal untuk membetulkan source code ini. Sebab crp.c adalah kod C yang sempurna di Linux Mint 12. Akhirnya saya mengambil keputusan untuk compile crp.c dengan menggunakan Tiny C Compiler. Invoked tcc -c crp.c dan tcc memberikan error ini:
crp.c:147: incompatible types for redefinition of 'SynError'Masaalah sama. Ia tentang types dan tentang "SynError" (juga "SemError", tapi tcc tak dapat detect error ini. gcc walaubagaimanapun dapat detect masaalah symbol "SemError"). Nampaknya ia bukan masaalah compiler MingW lagi kerana kedua-dua compiler gcc dan tcc dapat detect error yang sama.
Buntu mencari penyelesaian, saya cuba pula mencari consultation melalui IRC di server IRC Linux Mint. Di server berkenaan ada satu channel bernama "#mingw" dan ia rupanya satu channel unofficial bagi project MingW. Saya cuba menanyakan soal ini di channel berkenaan dan beberapa orang tampil untuk membantu. Ada juga yang menanyakan tentang Coco/R sendiri, kerana ia satu project yang tidak famous berbanding project lain. Coco/R adalah satu program untuk menghasilkan compiler lain. Ia seperti tool lex dan yacc bersama dalam satu pakej. Malang sekali, tak ada penyelesaian dapat dicapai dalam sesi consultation tersebut. Cuma saya dinasihatkan untuk examine kod crp.c tersebut dalam bentuk yang dah di preprocessed. Saya invoke lagi gcc -E -o crp-pre.c crp.c untuk mendapatkan output crp.c yang dah di preprocessed. Ini adalah crp-pre.c:
# 1 "crp.c" # 1 "Long story shorts, saya spotted error dari declaration SynError dan SemError. Ia di declared sebagai void SynError(int errno); untuk SynError dan void SemError(int errno); untuk SemError. Bagi saya yang baru didalam C ini, saya kurang memahami tentang apa masaalah disini, cuma saya hanya tahu, declaration dalam file header mestilah sama dengan assignment (saya belajar ini dari pengalaman dengan Pascal). Contohnya SynError dideclare void SynError(int errno); tapi di dalam crp.c, ia function SynError digunakan sebagai void SynError(int (*_errno())). The "*" dan "_" missing. Jeng jeng jeng.. Saya kemudian mengubah crp.h dengan mengantikan void SynError(int errno); kepada void SynError(int (*_errno())); dan void SemError(int errno); kepada void SemError(int (*_errno()));. Guess what, gcc dan even tcc telah berjaya compile crp.c dan berjaya link semua object lain membentuk file cocor.exe! I'm actually spotted error yang susah nak ditemui hurray! Ini adalah crp.h dengan modifikasi dari saya:" # 1 " " # 1 "crp.c" # 11 "crp.c" # 1 "crs.h" 1 # 14 "crs.h" # 1 "crc.h" 1 # 15 "crs.h" 2 # 23 "crs.h" extern int S_src; extern int S_Line, S_Col; extern int S_Len; extern long S_Pos; extern int S_NextLine; extern int S_NextCol; extern int S_NextLen; extern long S_NextPos; extern int S_CurrLine; extern long S_lineStart; int S_Get(void); void S_Reset(void); void S_GetString(long pos, int len, char *s, int max); void S_GetName(long pos, int len, char *s, int max); unsigned char S_CurrentCh(long pos); # 12 "crp.c" 2 # 1 "crp.h" 1 # 14 "crp.h" typedef void (*Error_Func) (int nr, int line, int col, long pos); void Parse(void); int Successful(void); void SynError(int errno); void SemError(int errno); # 13 "crp.c" 2 # 1 "crt.h" 1 # 1 "collect.h" 1 typedef void (*Collection_FuncPos) (void *object, int pos); typedef void (*Collection_Func) (void *object); typedef int (*Collection_Comp) (void *object, void *data); typedef struct { int el_size; int n_ext; int size; int el_free; char *data; } Collection; typedef Collection *PCollection; void Collection_Init(PCollection Col, int elem_s, int size, int extend); void Collection_Done(PCollection Col); void Collection_Clean(PCollection Col); int Collection_New(PCollection Col); int Collection_Count(PCollection Col); void *Collection_At(PCollection Col, int pos); void Collection_Get(PCollection Col, int pos, void *data); void Collection_Put(PCollection Col, int pos, void *data); void Collection_ForEach(PCollection Col, Collection_Func fn); void Collection_ForEachPos(PCollection Col, Collection_FuncPos fn); int Collection_FirstThat(PCollection Col, Collection_Comp fn, void *data); # 4 "crt.h" 2 # 1 "set.h" 1 typedef void (*Set_Func) (int object); typedef struct { int size; unsigned short int *data; } Set; typedef Set * PSet; void Set_Init(PSet set); void Set_Done(PSet set); void Set_Clean(PSet set); void Set_AddItem(PSet set, int n); void Set_DelItem(PSet set, int n); int Set_IsItem(PSet set, int n); int Set_MaxIndex(PSet set); int Set_MinIndex(PSet set); void Set_GetRange(PSet set, int *s, int *f); int Set_Elements(PSet set); int Set_Empty(PSet set); void Set_ForEach(PSet set, Set_Func fn); void Set_Union(PSet set1, PSet set2); void Set_Copy(PSet set1, PSet set2); void Set_Diference(PSet set1, PSet set2); void Set_Intersect(PSet set1, PSet set2); void Set_AddRange(PSet set, int start, int end); void Set_DelRange(PSet set, int start, int end); int Set_Equal(PSet set1, PSet set2); int Set_Diferent(PSet set1, PSet set2); int Set_Includes(PSet set, PSet set2); void Set_PrintInt(PSet set); void Set_PrintChar(PSet set); # 5 "crt.h" 2 # 1 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 1 3 # 19 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 # 1 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/_mingw.h" 1 3 # 32 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/_mingw.h" 3 # 33 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/_mingw.h" 3 # 20 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 2 3 # 1 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/include/stddef.h" 1 3 4 # 212 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/include/stddef.h" 3 4 typedef unsigned int size_t; # 324 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/include/stddef.h" 3 4 typedef short unsigned int wchar_t; # 353 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/include/stddef.h" 3 4 typedef short unsigned int wint_t; # 27 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 2 3 # 1 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/include/stdarg.h" 1 3 4 # 40 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/include/stdarg.h" 3 4 typedef __builtin_va_list __gnuc_va_list; # 29 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 2 3 # 129 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 typedef struct _iobuf { char* _ptr; int _cnt; char* _base; int _flag; int _file; int _charbuf; int _bufsiz; char* _tmpfname; } FILE; # 154 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 extern __attribute__ ((__dllimport__)) FILE _iob[]; # 169 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fopen (const char*, const char*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) freopen (const char*, const char*, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fflush (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fclose (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) remove (const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) rename (const char*, const char*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) tmpfile (void); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) tmpnam (char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _tempnam (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _rmtmp(void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _unlink (const char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) tempnam (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) rmtmp(void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) unlink (const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) setvbuf (FILE*, char*, int, size_t); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) setbuf (FILE*, char*); # 204 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_fprintf(FILE*, const char*, ...); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_printf(const char*, ...); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_sprintf(char*, const char*, ...); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_snprintf(char*, size_t, const char*, ...); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_vfprintf(FILE*, const char*, __gnuc_va_list); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_vprintf(const char*, __gnuc_va_list); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_vsprintf(char*, const char*, __gnuc_va_list); extern int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __mingw_vsnprintf(char*, size_t, const char*, __gnuc_va_list); # 293 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fprintf (FILE*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) printf (const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) sprintf (char*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vfprintf (FILE*, const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vprintf (const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vsprintf (char*, const char*, __gnuc_va_list); # 308 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_fprintf(FILE*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_printf(const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_sprintf(char*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_vfprintf(FILE*, const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_vprintf(const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __msvcrt_vsprintf(char*, const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _snprintf (char*, size_t, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _vsnprintf (char*, size_t, const char*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _vscprintf (const char*, __gnuc_va_list); # 331 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) snprintf (char *, size_t, const char *, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vsnprintf (char *, size_t, const char *, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vscanf (const char * __restrict__, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vfscanf (FILE * __restrict__, const char * __restrict__, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vsscanf (const char * __restrict__, const char * __restrict__, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fscanf (FILE*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) scanf (const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) sscanf (const char*, const char*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetc (FILE*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgets (char*, int, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputc (int, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputs (const char*, FILE*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) gets (char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) puts (const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ungetc (int, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _filbuf (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _flsbuf (int, FILE*); extern __inline__ int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getc (FILE* __F) { return (--__F->_cnt >= 0) ? (int) (unsigned char) *__F->_ptr++ : _filbuf (__F); } extern __inline__ int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putc (int __c, FILE* __F) { return (--__F->_cnt >= 0) ? (int) (unsigned char) (*__F->_ptr++ = (char)__c) : _flsbuf (__c, __F); } extern __inline__ int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getchar (void) { return (--(&_iob[0])->_cnt >= 0) ? (int) (unsigned char) *(&_iob[0])->_ptr++ : _filbuf ((&_iob[0])); } extern __inline__ int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putchar(int __c) { return (--(&_iob[1])->_cnt >= 0) ? (int) (unsigned char) (*(&_iob[1])->_ptr++ = (char)__c) : _flsbuf (__c, (&_iob[1]));} # 412 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fread (void*, size_t, size_t, FILE*); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fwrite (const void*, size_t, size_t, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fseek (FILE*, long, int); long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ftell (FILE*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) rewind (FILE*); # 455 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 typedef long long fpos_t; int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetpos (FILE*, fpos_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fsetpos (FILE*, const fpos_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) feof (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ferror (FILE*); # 480 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) clearerr (FILE*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) perror (const char*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _popen (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _pclose (FILE*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) popen (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) pclose (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _flushall (void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fgetchar (void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fputchar (int); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fdopen (int, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fileno (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fcloseall (void); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fsopen (const char*, const char*, int); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _getmaxstdio (void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _setmaxstdio (int); # 522 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetchar (void); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputchar (int); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fdopen (int, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fileno (FILE*); # 534 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 # 1 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/sys/types.h" 1 3 # 21 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/sys/types.h" 3 # 1 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/include/stddef.h" 1 3 4 # 150 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/include/stddef.h" 3 4 typedef int ptrdiff_t; # 22 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/sys/types.h" 2 3 typedef long __time32_t; typedef long long __time64_t; # 45 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/sys/types.h" 3 typedef __time32_t time_t; typedef long _off_t; typedef _off_t off_t; typedef unsigned int _dev_t; typedef _dev_t dev_t; typedef short _ino_t; typedef _ino_t ino_t; typedef int _pid_t; typedef _pid_t pid_t; typedef unsigned short _mode_t; typedef _mode_t mode_t; typedef int _sigset_t; typedef _sigset_t sigset_t; typedef int _ssize_t; typedef _ssize_t ssize_t; typedef long long fpos64_t; typedef long long off64_t; typedef unsigned int useconds_t; # 535 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 2 3 extern __inline__ FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fopen64 (const char* filename, const char* mode) { return fopen (filename, mode); } int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fseeko64 (FILE*, off64_t, int); extern __inline__ off64_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ftello64 (FILE * stream) { fpos_t pos; if (fgetpos(stream, &pos)) return -1LL; else return ((off64_t) pos); } # 563 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fwprintf (FILE*, const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wprintf (const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _snwprintf (wchar_t*, size_t, const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vfwprintf (FILE*, const wchar_t*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vwprintf (const wchar_t*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _vsnwprintf (wchar_t*, size_t, const wchar_t*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _vscwprintf (const wchar_t*, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fwscanf (FILE*, const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wscanf (const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) swscanf (const wchar_t*, const wchar_t*, ...); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetwc (FILE*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputwc (wchar_t, FILE*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ungetwc (wchar_t, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) swprintf (wchar_t*, const wchar_t*, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vswprintf (wchar_t*, const wchar_t*, __gnuc_va_list); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetws (wchar_t*, int, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputws (const wchar_t*, FILE*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getwc (FILE*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getwchar (void); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _getws (wchar_t*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putwc (wint_t, FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _putws (const wchar_t*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putwchar (wint_t); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfdopen(int, const wchar_t *); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfopen (const wchar_t*, const wchar_t*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfreopen (const wchar_t*, const wchar_t*, FILE*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfsopen (const wchar_t*, const wchar_t*, int); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wtmpnam (wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wtempnam (const wchar_t*, const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wrename (const wchar_t*, const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wremove (const wchar_t*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wperror (const wchar_t*); FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wpopen (const wchar_t*, const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) snwprintf (wchar_t* s, size_t n, const wchar_t* format, ...); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, __gnuc_va_list arg); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vwscanf (const wchar_t * __restrict__, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vfwscanf (FILE * __restrict__, const wchar_t * __restrict__, __gnuc_va_list); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) vswscanf (const wchar_t * __restrict__, const wchar_t * __restrict__, __gnuc_va_list); # 625 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdio.h" 3 FILE* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wpopen (const wchar_t*, const wchar_t*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fgetwchar (void); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fputwchar (wint_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _getw (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _putw (int, FILE*); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fgetwchar (void); wint_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fputwchar (wint_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getw (FILE*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putw (int, FILE*); # 6 "crt.h" 2 # 20 "crt.h" typedef unsigned char byte; struct SemText{ long pos; int line,len, col; }; typedef char Name[32]; typedef char *PName; # 67 "crt.h" typedef struct { int type; int next; long pointer1; int pointer2; int pointer3; int pointer4; int SLine; } GraphNode; typedef GraphNode *PGraphNode; # 96 "crt.h" int MakeGraph(int type, int sem_link); int MakeSemGraph(int type, long filepos, int len, int line, int col); int MakeGraphOp(int type, int link); int LinkGraph(int current, int next); int LinkAltGraph(int current, int nextalt); void SetGraphLine(int current, int line); void ShowGraph(int graph); void CleanGraphTab(void); typedef struct { Name name; Name gen_name; byte type; } TermNode; typedef TermNode* PTermNode; int FindTerm(PName name); void SetTermName(PTermNode tn); int NewTerm(PName name); void GetTermName(int sp, PName name); void ShowTermTab(void); typedef struct { Name name; Set data; } ClassNode; typedef ClassNode *PClassNode; int FindClass(PName name); int FindClassWithSet(PSet data); int GetClassWithName(PName name, Set *data); int GetClassWithData(PSet data); int NewClass(PName name, PSet set); void ShowClassTab(void); # 151 "crt.h" typedef struct { Set set; byte type; } SymSetNode; typedef SymSetNode *PSymSetNode; int NewSymSet(PSet set, byte typ); int NewANY(void); void GetSymSet(int index, PSet set); void IncludeSymSet(int index, PSet set); void ExcludeSymSet(int index, PSet set); void ShowSymSetTab(void); typedef struct { Name name; int graph; int has_attr; int attr; int sem; int line_dec; int line_use; int nullable; int ready; int reachable; Set first; Set follow; Set AuxNt; } NTermNode; typedef NTermNode *PNTermNode; int FindNTerm(PName name); int NewNTerm(PName name); void ShowNTermTab(void); typedef struct { Name name; int has_attr; struct SemText sem_text; } PragmaNode; typedef PragmaNode *PPragmaNode; int FindPragma(PName name); int NewPragma(PName name); void SetPragmaText(int sp, int gp); void SetupPragmas(void); # 217 "crt.h" typedef struct { Name name; Name user_name; } NameNode; typedef NameNode *PNameNode; int FindName(PName name); void NewName(PName name, PName user_name); void upcase(char *s); void AddIgnore(PSet set); int NewSym(PName name, int typ); int FindSym(PName name, int *typ); void InitTab(void); void DoneTab(void); int IsNullableGraph(int gp); void CompFirstSet(int gp, PSet first); void CompExpected(int gp, int nt, PSet set); void CompFollowNode(int gp, int fgp); void CompSymbolSets(void); void PrintAscii(int s); void PrintInt(int i); void SetOptions(char *s); extern void GenSemError(int nr); extern Collection nterm_tab; extern Collection term_tab; extern Collection nodes_tab; extern Collection class_tab; extern Collection symset_tab; extern Collection pragma_tab; extern Collection name_tab; extern struct SemText global_defs; extern int dirty_DFA; extern int ignore_case; extern int first_weak_set; extern int no_sym; extern FILE *lstfile; extern Set ANY_SET; extern Set ALL_TERMS; extern int C_option; extern int F_option; extern int G_option; extern int L_option; extern int P_option; extern int Q_option; extern int O_option; extern int S_option; extern int T_option; extern int A_option; extern int D_option; extern int Z_option; extern int GenCplusplus; extern char Frames_Path[]; extern char c_ext[]; extern char h_ext[]; # 15 "crp.c" 2 # 1 "crf.h" 1 void GenCode(FILE *out, char *fmt, ...); void SymCharName(unsigned char c, char *asciiname); FILE *OpenFile(char *name, char *opt, int GenError); void InitFrameVars(void); void SetupFrameVars(void); void GenScanner(void); void GenParser(void); void GenHeaders(void); void GenCompiler(void); extern char compiler_name[]; extern char module_prefix[]; extern char source_name[]; # 16 "crp.c" 2 # 1 "cra.h" 1 typedef struct { int type; int sym; int tc; Set to_states; } TransNode; typedef TransNode *PTransNode; typedef struct { Collection trans_list; int end_of; int ctx; int gen_state_no; } StateNode; typedef StateNode *PStateNode; typedef struct { Set set; int state; } MeltedNode; typedef MeltedNode *PMeltedNode; typedef struct { char start_token[3]; char end_token[3]; int nested; } CommentNode; typedef CommentNode *PCommentNode; void NewComment(int start_token, int end_token, int nested); void ShowCommentTab(void); void ConvertToStates(int gp, int sp); int StrToGraph(byte *name); int MatchDFA(byte *str, int sp); int MakeDeterministic(void); void MakeScanner(void); void InitScannerTab(void); void DoneScannerTab(void); void ShowDFA(void); # 17 "crp.c" 2 # 1 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/string.h" 1 3 # 24 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/string.h" 3 # 1 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/include/stddef.h" 1 3 4 # 25 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/string.h" 2 3 # 36 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/string.h" 3 void* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) memchr (const void*, int, size_t) __attribute__ ((__pure__)); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) memcmp (const void*, const void*, size_t) __attribute__ ((__pure__)); void* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) memcpy (void*, const void*, size_t); void* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) memmove (void*, const void*, size_t); void* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) memset (void*, int, size_t); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strcat (char*, const char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strchr (const char*, int) __attribute__ ((__pure__)); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strcmp (const char*, const char*) __attribute__ ((__pure__)); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strcoll (const char*, const char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strcpy (char*, const char*); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strcspn (const char*, const char*) __attribute__ ((__pure__)); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strerror (int); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strlen (const char*) __attribute__ ((__pure__)); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strncat (char*, const char*, size_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strncmp (const char*, const char*, size_t) __attribute__ ((__pure__)); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strncpy (char*, const char*, size_t); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strpbrk (const char*, const char*) __attribute__ ((__pure__)); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strrchr (const char*, int) __attribute__ ((__pure__)); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strspn (const char*, const char*) __attribute__ ((__pure__)); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strstr (const char*, const char*) __attribute__ ((__pure__)); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strtok (char*, const char*); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strxfrm (char*, const char*, size_t); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _strerror (const char *); void* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _memccpy (void*, const void*, int, size_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _memicmp (const void*, const void*, size_t); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _strdup (const char*) __attribute__ ((__malloc__)); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _strcmpi (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _stricmp (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _stricoll (const char*, const char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _strlwr (char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _strnicmp (const char*, const char*, size_t); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _strnset (char*, int, size_t); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _strrev (char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _strset (char*, int); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _strupr (char*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _swab (const char*, char*, size_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _strncoll(const char*, const char*, size_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _strnicoll(const char*, const char*, size_t); # 90 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/string.h" 3 void* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) memccpy (void*, const void*, int, size_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) memicmp (const void*, const void*, size_t); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strdup (const char*) __attribute__ ((__malloc__)); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strcmpi (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) stricmp (const char*, const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strcasecmp (const char*, const char *); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) stricoll (const char*, const char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strlwr (char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strnicmp (const char*, const char*, size_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strncasecmp (const char *, const char *, size_t); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strnset (char*, int, size_t); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strrev (char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strset (char*, int); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strupr (char*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) swab (const char*, char*, size_t); # 126 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/string.h" 3 wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcscat (wchar_t*, const wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcschr (const wchar_t*, wchar_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcscmp (const wchar_t*, const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcscoll (const wchar_t*, const wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcscpy (wchar_t*, const wchar_t*); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcscspn (const wchar_t*, const wchar_t*); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcslen (const wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsncat (wchar_t*, const wchar_t*, size_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsncmp(const wchar_t*, const wchar_t*, size_t); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsncpy(wchar_t*, const wchar_t*, size_t); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcspbrk(const wchar_t*, const wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsrchr(const wchar_t*, wchar_t); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsspn(const wchar_t*, const wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsstr(const wchar_t*, const wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcstok(wchar_t*, const wchar_t*); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsxfrm(wchar_t*, const wchar_t*, size_t); # 152 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/string.h" 3 wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wcsdup (const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wcsicmp (const wchar_t*, const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wcsicoll (const wchar_t*, const wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wcslwr (wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wcsnicmp (const wchar_t*, const wchar_t*, size_t); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wcsnset (wchar_t*, wchar_t, size_t); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wcsrev (wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wcsset (wchar_t*, wchar_t); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wcsupr (wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wcsncoll(const wchar_t*, const wchar_t*, size_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wcsnicoll(const wchar_t*, const wchar_t*, size_t); # 173 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/string.h" 3 int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcscmpi (const wchar_t * __ws1, const wchar_t * __ws2); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsdup (const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsicmp (const wchar_t*, const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsicoll (const wchar_t*, const wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcslwr (wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsnicmp (const wchar_t*, const wchar_t*, size_t); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsnset (wchar_t*, wchar_t, size_t); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsrev (wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsset (wchar_t*, wchar_t); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcsupr (wchar_t*); # 20 "crp.c" 2 # 1 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 1 3 # 21 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 # 1 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/include/stddef.h" 1 3 4 # 22 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 2 3 # 71 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 extern int _argc; extern char** _argv; extern int* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __p___argc(void); extern char*** __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __p___argv(void); extern wchar_t*** __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __p___wargv(void); # 112 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 extern __attribute__ ((__dllimport__)) int __mb_cur_max; # 137 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 int* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _errno(void); int* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __doserrno(void); # 149 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 extern char *** __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __p__environ(void); extern wchar_t *** __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __p__wenviron(void); # 172 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 extern __attribute__ ((__dllimport__)) int _sys_nerr; # 196 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 extern __attribute__ ((__dllimport__)) char* _sys_errlist[]; # 209 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 extern unsigned __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) int* __p__osver(void); extern unsigned __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) int* __p__winver(void); extern unsigned __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) int* __p__winmajor(void); extern unsigned __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) int* __p__winminor(void); extern __attribute__ ((__dllimport__)) unsigned int _osver; extern __attribute__ ((__dllimport__)) unsigned int _winver; extern __attribute__ ((__dllimport__)) unsigned int _winmajor; extern __attribute__ ((__dllimport__)) unsigned int _winminor; # 260 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 char** __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __p__pgmptr(void); wchar_t** __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __p__wpgmptr(void); # 293 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 extern __attribute__ ((__dllimport__)) int _fmode; # 303 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 double __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) atof (const char*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) atoi (const char*); long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) atol (const char*); double __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wtof (const wchar_t *); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wtoi (const wchar_t *); long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wtol (const wchar_t *); double __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) __strtod (const char*, char**); extern double __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strtod (const char* __restrict__ __nptr, char** __restrict__ __endptr); float __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strtof (const char * __restrict__, char ** __restrict__); long double __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strtold (const char * __restrict__, char ** __restrict__); long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strtol (const char*, char**, int); unsigned long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strtoul (const char*, char**, int); long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcstol (const wchar_t*, wchar_t**, int); unsigned long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcstoul (const wchar_t*, wchar_t**, int); double __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcstod (const wchar_t*, wchar_t**); float __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcstof( const wchar_t * __restrict__, wchar_t ** __restrict__); long double __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcstold (const wchar_t * __restrict__, wchar_t ** __restrict__); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wgetenv(const wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wputenv(const wchar_t*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wsearchenv(const wchar_t*, const wchar_t*, wchar_t*); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wsystem(const wchar_t*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wmakepath(wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wsplitpath (const wchar_t*, wchar_t*, wchar_t*, wchar_t*, wchar_t*); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wfullpath (wchar_t*, const wchar_t*, size_t); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wcstombs (char*, const wchar_t*, size_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wctomb (char*, wchar_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) mblen (const char*, size_t); size_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) mbstowcs (wchar_t*, const char*, size_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) mbtowc (wchar_t*, const char*, size_t); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) rand (void); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) srand (unsigned int); void* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) calloc (size_t, size_t) __attribute__ ((__malloc__)); void* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) malloc (size_t) __attribute__ ((__malloc__)); void* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) realloc (void*, size_t); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) free (void*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) abort (void) __attribute__ ((__noreturn__)); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) exit (int) __attribute__ ((__noreturn__)); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) atexit (void (*)(void)); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) system (const char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) getenv (const char*); void* __attribute__((__cdecl__)) bsearch (const void*, const void*, size_t, size_t, int (*)(const void*, const void*)); void __attribute__((__cdecl__)) qsort(void*, size_t, size_t, int (*)(const void*, const void*)); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) abs (int) __attribute__ ((__const__)); long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) labs (long) __attribute__ ((__const__)); # 385 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 typedef struct { int quot, rem; } div_t; typedef struct { long quot, rem; } ldiv_t; div_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) div (int, int) __attribute__ ((__const__)); ldiv_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ldiv (long, long) __attribute__ ((__const__)); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _beep (unsigned int, unsigned int) __attribute__ ((__deprecated__)); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _seterrormode (int) __attribute__ ((__deprecated__)); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _sleep (unsigned long) __attribute__ ((__deprecated__)); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _exit (int) __attribute__ ((__noreturn__)); typedef int (* _onexit_t)(void); _onexit_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _onexit( _onexit_t ); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _putenv (const char*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _searchenv (const char*, const char*, char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _ecvt (double, int, int*, int*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fcvt (double, int, int*, int*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _gcvt (double, int, char*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _makepath (char*, const char*, const char*, const char*, const char*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _splitpath (const char*, char*, char*, char*, char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _fullpath (char*, const char*, size_t); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _itoa (int, char*, int); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _ltoa (long, char*, int); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _ultoa(unsigned long, char*, int); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _itow (int, wchar_t*, int); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _ltow (long, wchar_t*, int); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _ultow (unsigned long, wchar_t*, int); long long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _atoi64(const char *); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _i64toa(long long, char *, int); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _ui64toa(unsigned long long, char *, int); long long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _wtoi64(const wchar_t *); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _i64tow(long long, wchar_t *, int); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _ui64tow(unsigned long long, wchar_t *, int); unsigned int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) (_rotl)(unsigned int, int) __attribute__ ((__const__)); unsigned int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) (_rotr)(unsigned int, int) __attribute__ ((__const__)); unsigned long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) (_lrotl)(unsigned long, int) __attribute__ ((__const__)); unsigned long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) (_lrotr)(unsigned long, int) __attribute__ ((__const__)); int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _set_error_mode (int); # 477 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 int __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) putenv (const char*); void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) searchenv (const char*, const char*, char*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) itoa (int, char*, int); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ltoa (long, char*, int); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ecvt (double, int, int*, int*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) fcvt (double, int, int*, int*); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) gcvt (double, int, char*); # 497 "c:\\gcc\\bin\\../lib/gcc/mingw32/4.6.2/../../../../include/stdlib.h" 3 void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _Exit(int) __attribute__ ((__noreturn__)); typedef struct { long long quot, rem; } lldiv_t; lldiv_t __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) lldiv (long long, long long) __attribute__ ((__const__)); long long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) llabs(long long); long long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strtoll (const char* __restrict__, char** __restrict, int); unsigned long long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) strtoull (const char* __restrict__, char** __restrict__, int); long long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) atoll (const char *); long long __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) wtoll (const wchar_t *); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) lltoa (long long, char *, int); char* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ulltoa (unsigned long long , char *, int); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) lltow (long long, wchar_t *, int); wchar_t* __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) ulltow (unsigned long long, wchar_t *, int); # 21 "crp.c" 2 static void FixString(char *name) { int i, j, len, spaces, start; len = strlen(name); if (len == 2) { SemError(129); return; } if (ignore_case) upcase(name); spaces = 0; start = name[0]; for (i = 1; i <= len-2; i++) { if (name[i] > 0 && name[i] <= ' ') spaces = 1; if (name[i] == '\\') { if (name[i+1] == '\\' || name[i+1] == '\'' || name[i+1] == '\"') { for (j = i; j < len; j++) name[j] = name[j+1]; len--; } } } if (spaces) SemError(124); } static void MatchLiteral (int sp) { PTermNode sn, sn1; int matched_sp; sn = (PTermNode) Collection_At(&term_tab, sp); matched_sp = MatchDFA((unsigned char *) sn->name, sp); if (matched_sp != 0) { sn1 = (PTermNode) Collection_At(&term_tab, matched_sp); sn1->type = 2; sn->type = 3; } else sn->type= 1; } static void SetCtx (int gp) { PGraphNode gn; while (gp > 0) { gn = (PGraphNode) Collection_At(&nodes_tab, gp); if (gn->type == 1 || gn->type == 2) gn->pointer4 = 1; else if (gn->type == 4 || gn->type == 5) SetCtx(gn->pointer1); else if (gn->type == 6) { SetCtx(gn->pointer1); SetCtx(gn->pointer2); } gp = gn->next; } } static void StringClass(char *s, Set *items) { s[strlen(s)-1]=0; s++; while (*s) Set_AddItem(items, *s++); } Error_Func Custom_Error = 0L; static int Sym; static int errors = 0; static int ErrDist = 2; static void CR(void); static void Ident(char *s); static void Declaration(int *startedDFA); static void Attribs(int *n); static void SemText(int *n); static void Expression(int *n); static void SetDecl(void); static void TokenDecl(int sec_type); static void NameDecl(void); static void TokenExpr(int *n); static void CompSet(PSet items); static void SimSet(PSet items); static void String(char *s); static void ChrSet(int *n); static void Term(int *n); static void Factor(int *n); static void Symbol(char *name); static void TokenTerm(int *n); static void TokenFactor(int *n); static unsigned short int SymSet[][3] = { {0x7EC7,0x4,0x80}, {0x106,0xBA80,0x82}, {0x202,0x0,0x0}, {0x100,0x4400,0x1}, {0x106,0xFE80,0x83}, {0x7D40,0x4407,0x1}, {0x6,0xA200,0x0}, {0x0} }; void GenError(int (*_errno())) { if (ErrDist >= 2) { if (Custom_Error != 0L) (*Custom_Error) ((*_errno()), S_NextLine, S_NextCol, S_NextPos); errors++; } ErrDist = 0; } void SynError(int (*_errno())) { if ((*_errno()) <= 63) (*_errno()) = 63; if (ErrDist >= 2) { if (Custom_Error != 0L) (*Custom_Error) ((*_errno()), S_NextLine, S_NextCol, S_NextPos); errors++; } ErrDist = 0; } void SemError(int (*_errno())) { if ((*_errno()) <= 63) (*_errno()) = 63; if (ErrDist >= 2) { if (Custom_Error != 0L) (*Custom_Error) ((*_errno()), S_Line, S_Col, S_Pos); errors++; } ErrDist = 0; } static void Get(void) { do { Sym = S_Get(); if (Sym <= 41) ErrDist ++; else { if (Sym == 42) { char s[100]; S_GetString(S_NextPos, S_NextLen, s, sizeof(s)-1); SetOptions(s); } else ; S_NextPos = S_Pos; S_NextCol = S_Col; S_NextLine = S_Line; S_NextLen = S_Len; } } while (Sym > 41); } static int In (unsigned short int *SymbolSet, int i) { return SymbolSet[i / 16] & (1 << (i % 16)); } static void Expect (int n) { if (Sym == n) Get(); else GenError(n); } static void ExpectWeak (int n, int follow) { if (Sym == n) Get(); else { GenError(n); while (!(In(SymSet[follow], Sym) || In(SymSet[0], Sym))) Get(); } } static int WeakSeparator (int n, int syFol, int repFol) { unsigned short int s[3]; int i; if (Sym == n) { Get(); return 1; } if (In(SymSet[repFol], Sym)) return 0; for (i = 0; i < 3; i++) s[i] = SymSet[0][i] | SymSet[syFol][i] | SymSet[repFol][i]; GenError(n); while (!In(s, Sym)) Get(); return In(SymSet[syFol], Sym); } int Successful(void) { return errors == 0; } static void CR(void) { Name name1; int attr, sem, exp, is_new, sp, type; int startedDFA = 0; PNTermNode sn; Expect(5); Ident(compiler_name); global_defs.pos = S_NextPos; global_defs.line = S_NextLine; while (Sym >= 1 && Sym <= 5 || Sym >= 7 && Sym <= 9 || Sym >= 15 && Sym <= 17 || Sym >= 19 && Sym <= 41) { Get(); } global_defs.len = (int) (S_NextPos-global_defs.pos); while (Sym >= 10 && Sym <= 14 || Sym == 18) { Declaration(&startedDFA); } while (!(Sym == 0 || Sym == 6)) { GenError(43); Get(); } if (Successful()) { if (!MakeDeterministic()) SemError(127); }; Expect(6); while (Sym == 1) { attr = 0; sem = 0; Ident(name1); if ((sp = FindSym(name1, &type)) != -1) { is_new = 0; if (type != 3) { SemError(108); return; } else { sn = (PNTermNode) Collection_At(&nterm_tab, sp); if (sn->graph) SemError(107); sn->line_dec = S_Line; } } else { sp = NewSym(name1, 3); sn = (PNTermNode) Collection_At(&nterm_tab, sp); is_new = 1; sn->line_dec = S_Line; }; if (Sym == 35 || Sym == 37) { Attribs(&attr); } if (!is_new) { if (sn->has_attr && !attr) SemError(105); if (!sn->has_attr && attr) SemError(105); } if (attr) { sn->attr = attr; sn->has_attr = 1; }; ExpectWeak(7,1); if (Sym == 39) { SemText(&sem); } Expression(&exp); if (sem) { (void) LinkGraph(sem, exp); exp = sem; }; ExpectWeak(8,2); sn = (PNTermNode) Collection_At(&nterm_tab, sp); sn->graph = exp; while (!(Sym >= 0 && Sym <= 1 || Sym == 9)) { GenError(44); Get(); } } Expect(9); Ident(name1); if (strcmp(name1, compiler_name)) SemError(117); if((sp = FindSym(compiler_name, &type)) != -1) { if (type!=3) SemError(108); else { sn = (PNTermNode) Collection_At(&nterm_tab, sp); if (sn->has_attr) SemError(112); sn->reachable=1; } } else SemError(111); no_sym = NewSym("not", 1); Expect(8); if (dirty_DFA && !MakeDeterministic()) SemError(127); } static void Ident(char *s) { Expect(1); S_GetString(S_Pos, S_Len, s, 32 -1); } static void Declaration(int *startedDFA) { Set ignore; int n1, n2, nested = 0; switch (Sym) { case 10: Get(); while (Sym == 1) { SetDecl(); } break; case 11: Get(); while (Sym >= 1 && Sym <= 2) { TokenDecl(1); } break; case 12: Get(); while (Sym == 1) { NameDecl(); } break; case 13: Get(); while (Sym >= 1 && Sym <= 2) { TokenDecl(11); } break; case 14: Get(); Expect(15); TokenExpr(&n1); Expect(16); TokenExpr(&n2); if (Sym == 17) { Get(); nested = 1; } if (n1 * n2) NewComment(n1, n2, nested); break; case 18: Get(); if (Sym == 19) { Get(); if (*startedDFA) SemError(130); ignore_case = 1; } else if (Sym >= 1 && Sym <= 2 || Sym >= 23 && Sym <= 24) { Set_Init(&ignore); CompSet(&ignore); AddIgnore(&ignore); if (Set_IsItem(&ignore,0)) SemError(119); Set_Done(&ignore); } else GenError(45); break; default :GenError(46); break; } *startedDFA = 1; } static void Attribs(int *n) { long P; int Len, Line, Col; if (Sym == 35) { Get(); P = S_Pos+1; Line = S_Line; Col = S_Col; while (Sym >= 1 && Sym <= 35 || Sym >= 37 && Sym <= 41) { if (Sym >= 1 && Sym <= 2 || Sym >= 4 && Sym <= 35 || Sym >= 37 && Sym <= 41) { Get(); } else if (Sym == 3) { Get(); SemError(102); } else GenError(47); } Expect(36); Len = (int) (S_Pos - P); *n = MakeSemGraph(8, P, Len, Line, Col); } else if (Sym == 37) { Get(); P = S_Pos+2; Line = S_Line; Col = S_Col; while (Sym >= 1 && Sym <= 37 || Sym >= 39 && Sym <= 41) { if (Sym >= 1 && Sym <= 2 || Sym >= 4 && Sym <= 37 || Sym >= 39 && Sym <= 41) { Get(); } else if (Sym == 3) { Get(); SemError(102); } else GenError(48); } Expect(38); Len = (int) (S_Pos - P); *n = MakeSemGraph(8, P, Len, Line, Col); } else GenError(49); } static void SemText(int *n) { long P; int Len, Line, Col; Expect(39); P = S_Pos+2; Line = S_Line; Col = S_Col; while (Sym >= 1 && Sym <= 39 || Sym == 41) { if (Sym >= 1 && Sym <= 2 || Sym >= 4 && Sym <= 38 || Sym == 41) { Get(); } else if (Sym == 3) { Get(); SemError(102); } else if (Sym == 39) { Get(); SemError(109); } else GenError(50); } Expect(40); Len = (int) (S_Pos - P); *n = MakeSemGraph(7, P, Len, Line, Col); } static void Expression(int *n) { int n0 = 0, n1, n2, SX_Line; Term(&n1); while (WeakSeparator(27,4,3)) { if (n0 == 0) n0 = n1 = MakeGraph(6, n1); SX_Line = S_Line; Term(&n2); n2 = MakeGraph(6, n2); SetGraphLine(n2,SX_Line); n1 = LinkAltGraph(n1, n2); } *n = (n0 ? n0 : n1); } static void SetDecl(void) { Name name; Set items; Set_Init(&items); Ident(name); if (FindClass(name) != -1) SemError(107); Expect(7); CompSet(&items); Expect(8); if (Set_Empty(&items)) SemError(101); (void) NewClass(name, &items); Set_Done(&items); } static void TokenDecl(int sec_type) { char name[100]; int p = 0, sp, type; if (Sym == 1) { Ident(name); if ((sp = FindSym(name, &type)) != -1) SemError(107); else sp = NewSym(name, sec_type); while (!(Sym >= 0 && Sym <= 2 || Sym >= 6 && Sym <= 7 || Sym >= 10 && Sym <= 14 || Sym == 18 || Sym == 39)) { GenError(51); Get(); } if (Sym == 7) { Get(); TokenExpr(&p); if (sec_type == 1) ConvertToStates(p, sp); else ConvertToStates(p, sp+1024); Expect(8); } else if (Sym >= 1 && Sym <= 2 || Sym == 6 || Sym >= 10 && Sym <= 14 || Sym == 18 || Sym == 39) { P_option = 1; } else GenError(52); } else if (Sym == 2) { String(name); P_option = 1; if ((sp = FindSym(name, &type)) != -1) SemError(107); else sp = NewSym(name, sec_type); } else GenError(53); if (Sym == 39) { SemText(&p); if (sec_type == 1) SemError(114); else SetPragmaText(sp, p); } } static void NameDecl(void) { Name username, name; Ident(username); Expect(7); if (Sym == 1) { Ident(name); } else if (Sym == 2) { String(name); } else GenError(54); Expect(8); NewName(name, username); } static void TokenExpr(int *n) { int n0 = 0, n1, n2; TokenTerm(&n1); while (WeakSeparator(27,6,5)) { if (n0 == 0) n0 = n1 = MakeGraph(6, n1); TokenTerm(&n2); n2 = MakeGraph(6, n2); n1 = LinkAltGraph(n1, n2); } *n = (n0 ? n0 : n1); } static void CompSet(PSet items) { Set set1, set2; Set_Init(&set1); Set_Init(&set2); SimSet(&set1); while (Sym >= 20 && Sym <= 21) { if (Sym == 20) { Get(); SimSet(&set2); Set_Union(&set1, &set2); } else if (Sym == 21) { Get(); SimSet(&set2); Set_Diference(&set1, &set2); } else GenError(55); Set_Clean(&set2); } Set_Union(items, &set1); Set_Done(&set1); Set_Done(&set2); } static void SimSet(PSet items) { Name name; char str[100]; int n1, n2; switch (Sym) { case 1: Ident(name); if (FindClass(name) == -1) SemError(115); GetClassWithName(name, items); break; case 2: String(str); StringClass(str, items); break; case 24: ChrSet(&n1); if (Sym == 22) { Get(); ChrSet(&n2); Set_AddRange(items, n1, n2); } else if (Sym == 6 || Sym == 8 || Sym >= 10 && Sym <= 14 || Sym == 18 || Sym >= 20 && Sym <= 21) { Set_AddItem(items, n1); } else GenError(56); break; case 23: Get(); Set_Union(items, &ANY_SET); break; default :GenError(57); break; } } static void String(char *s) { Expect(2); S_GetString(S_Pos, S_Len, s, 100 -1); FixString(s); } static void ChrSet(int *n) { char str[5]; int x; Expect(24); Expect(25); if (Sym == 4) { Get(); S_GetString(S_Pos, S_Len, str, sizeof(str)-1); x = atoi(str); if (x > 255) { SemError(118); x = 0; } *n = x; } else if (Sym == 2) { Get(); S_GetString(S_Pos, S_Len, str, sizeof(str)-1); if (strlen(str) != 3) SemError(118); *n = str[1]; } else GenError(58); Expect(26); } static void Term(int *n) { int n0 = 0, n1, n2; if (Sym >= 1 && Sym <= 2 || Sym == 23 || Sym == 25 || Sym >= 28 && Sym <= 29 || Sym == 31 || Sym == 33 || Sym == 39) { Factor(&n1); n0 = n1; while (Sym >= 1 && Sym <= 2 || Sym == 23 || Sym == 25 || Sym >= 28 && Sym <= 29 || Sym == 31 || Sym == 33 || Sym == 39) { Factor(&n2); n1 = LinkGraph(n1, n2); } } else if (Sym == 8 || Sym >= 26 && Sym <= 27 || Sym == 30 || Sym == 32) { n0 = MakeSemGraph(7, -1, 0, S_Line, S_Col); } *n = n0; } static void Factor(int *n) { char name1[100]; int weak = 0, SX_Line; int n1, n2 = 0; int sp, is_new, type; PNTermNode snt; switch (Sym) { case 1: case 2: case 28: if (Sym == 28) { Get(); weak = 1; } Symbol(name1); sp = FindSym(name1, &type); if (type == 2) SemError(104); if (weak && type == 1) type = 2; if (weak && type == 3) SemError(123); n1 = MakeGraph(type, sp); if (type == 3) { snt = (PNTermNode) Collection_At(&nterm_tab, sp); is_new = snt->graph == 0; snt->line_use = S_Line; snt->reachable = 1; }; if (Sym == 35 || Sym == 37) { Attribs(&n2); (void) LinkAltGraph(n1, n2); if (type != 3) SemError(103); else { if(!is_new && !snt->has_attr) SemError(105); if (is_new) snt->has_attr = 1; }; } else if (Sym >= 1 && Sym <= 2 || Sym == 8 || Sym == 23 || Sym >= 25 && Sym <= 33 || Sym == 39) { if (type == 3) if (!is_new && snt->has_attr) SemError(105); } else GenError(59); break; case 25: Get(); Expression(&n1); Expect(26); break; case 29: Get(); SX_Line = S_Line; Expression(&n1); Expect(30); n1 = MakeGraph(4, n1); SetGraphLine(n1,SX_Line); break; case 31: Get(); SX_Line = S_Line; Expression(&n1); Expect(32); n1 = MakeGraph(5, n1); SetGraphLine(n1,SX_Line); break; case 39: SemText(&n1); break; case 23: Get(); n1 = MakeGraph(9, 0); break; case 33: Get(); n1 = MakeGraph(10, 0); break; default :GenError(60); break; } *n = n1; } static void Symbol(char *name) { int sp, type; if (Sym == 1) { Ident(name); sp = FindSym(name, &type); if (sp == -1) sp = NewSym(name, 3); } else if (Sym == 2) { String(name); sp = FindSym(name, &type); if (sp == -1) { sp = NewSym(name, 1); MatchLiteral(sp); }; } else GenError(61); } static void TokenTerm(int *n) { int n0 = 0, n1, n2; TokenFactor(&n1); n0 = n1; while (Sym >= 1 && Sym <= 2 || Sym == 25 || Sym == 29 || Sym == 31) { TokenFactor(&n2); n1 = LinkGraph(n1, n2); } if (Sym == 34) { Get(); Expect(25); TokenExpr(&n2); Expect(26); SetCtx(n2); n1 = LinkGraph(n1, n2); } *n = n0; } static void TokenFactor(int *n) { char name[100]; int p = 0; switch (Sym) { case 1: Ident(name); if ((p = FindClass(name)) == -1) { p = MakeGraph(1, 0); SemError(115); } else p = MakeGraph(2, p); break; case 2: String(name); p = StrToGraph((unsigned char *) name); break; case 25: Get(); TokenExpr(&p); Expect(26); break; case 29: Get(); TokenExpr(&p); Expect(30); p = MakeGraphOp(4, p); break; case 31: Get(); TokenExpr(&p); Expect(32); p = MakeGraphOp(5, p); break; default :GenError(62); break; } *n = p; } void Parse(void) { S_Reset(); Get(); CR(); }
/********************************************************** ** PARSER_H.FRM ** Coco/R C Support Frames. ** Author: Frankie Arzu** Modification (2012): MrHarmonies ** ** Jun 12, 1996 Version 1.06 ** Many fixes and suggestions thanks to ** Pat Terry **********************************************************/ #ifndef PARSER_HEADER_INCLUDE #define PARSER_HEADER_INCLUDE typedef void (*Error_Func) (int nr, int line, int col, long pos); #define MinErrDist 2 #define MAXERROR 63 void Parse(void); /* Parse the source */ int Successful(void); /* Returns 1 if no errors have been recorded while parsing */ void SynError(int (*_errno())); void SemError(int (*_errno())); */ #define LexString(lex, size) S_GetString(S_Pos, S_Len, lex, size) /* Retrieves Lex as exact spelling of current token */ #define LexName(lex, size) S_GetName(S_Pos, S_Len, lex, size) /* Retrieves Lex as name of current token (capitalized if IGNORE CASE) */ #define LookAheadString(lex, size) S_GetString(S_NextPos, S_NextLen, lex, size) /* Retrieves Lex as exact spelling of lookahead token */ #define LookAheadName(lex, size) S_GetName(S_NextPos, S_NextLen, lex, size) /* Retrieves Lex as name of lookahead token (capitalized if IGNORE CASE) */ #endif /* PARSER_HEADER_INCLUDE */
Alhamdulillah! :) Terima kasih kerana sudi membaca. Selamat berprogramming!
Tiada ulasan: