| QUOTE |
| cool man if you made a built in text editor you could create a programming language |
| QUOTE |
| I think he means to create a Win32 program as an IDE sort of thing and it will save the code into Code.txt and the program will run main.exe or whatever. |
| CODE |
| is it posable to get tokens or is there a better method? |
| QUOTE |
| Any way very nice work, is there any way I could view the source for this great program? Just to use as a referance when I try to make my Java one? |
| CODE |
#include <windows.h> #include <iostream> #include <stdlib.h> using namespace std; char**stack; char**stack_top; void message(void) { stack[1][strlen(stack[1])-1]=0; cout<<stack[1]+1<<endl; } bool LoadIndex(void) { char*index; HANDLE file=CreateFile("code.txt",GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); if(file==INVALID_HANDLE_VALUE) { cout<<"Could not open code.txt"<<endl; system("pause"); return false; } int size=GetFileSize(file,0); index=new char[size+2]; index[size]=0; DWORD b; ReadFile(file,index,size,&b,NULL); CloseHandle(file); //Remove comment & new lines & taps bool string=false; bool comment=false; for(register char*i=index;*i!=0;i++) { if(string&&*i=='"') string=false; else if(comment) { if(*i==13) comment=false; *i=' '; } else switch(*i) { case '"': string=true; break; case '#': if(string) break; comment=true; case 9: case 13: if(string) break; *i=' '; case 10: if(string) break; *i='|'; } } //Remove mutiple Spaces (but not in ""s) and spaces before | string=false; for(register char*i=index;*i!=0;i++) { if(string&&*i=='"') string=false; else if(!string) switch(*i) { case '"': string=true; break; case ' ': if(*(i+1)==' '||*(i+1)=='|'||(i!=index&&*(i-1)=='|')) { memmove(i,i+1,strlen(i+1)); index[strlen(index)-1]=0; i--; } } } //Remove multiple |s (but not in ""s) string=false; for(register char*i=index;*i!=0;i++) { if(string&&*i=='"') string=false; else if(!string) switch(*i) { case '"': string=true; break; case '|': if(*(i+1)=='|'||(i==index&&*i=='|')) { memmove(i,i+1,strlen(i+1)); index[strlen(index)-1]=0; i--; } } } int last=strlen(index)-1; if(index[last]!='|') { index[last]='|'; index[last+1]=0; } //start interpreter //First we create the stack (best is to make it bigger than needed) stack=new char*[10]; stack_top=stack; //We need to conserve the original index to free the memory char*old_index=index; string=false; for(register char*i=index;*i!=0;i++) { if(string&&*i=='"') string=false; else if(!string) switch(*i) { case '"': string=true; break; //If we need to push data on the stack: case '|': case ' ': //we push the data on the stack char temp=*i; *i=0; *stack_top=index; stack_top++; //We delete what we have handled index=i+1; //we check if we not are supposed to execute a command if(temp==' ') break; if(strcmp(stack[0],"Message")==0) message(); else if(strcmp(stack[0],"Cls")==0) system("cls"); else if(strcmp(stack[0],"Pause")==0) system("Pause"); else cout<<"Unknown command for '"<<stack[0]<<"'"<<endl; stack_top=stack; } } delete[]index; delete[]stack; } main() { char*code; LoadIndex(); } |
| CODE |
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland C:\Documents and Settings\Familt\Desktop\test.cpp: Warning W8070 C:\Documents and Settings\Familt\Desktop\test.cpp 168: Function should return a value in function LoadIndex() Warning W8004 C:\Documents and Settings\Familt\Desktop\test.cpp 168: 'old_index' is assigned a value that is never used in function LoadIndex() Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland Error: Unresolved external 'WinMain' referenced from C:\BORLAND\BCC55\LIB\C0W32.OBJ |
| QUOTE |
| Unresolved external 'WinMain' referenced from C:\BORLAND\BCC55\LIB\C0W32.OBJ |
| QUOTE | ||
*Sigh*. Compile as a Win32 GUI application. |
| CODE |
| #This is my interpreter v0.1 not much for the moment #so I am quickly finished: #everything after a # is comment #everything between "s is a string and will not #be interpreted (althought it can be passed as #argument) #a | is an instruction seperator #All functions are used in this example Message "Hello Read code.txt for detail" Pause|Cls Message "Cls clears all lines"| Message "Because # and | are in quotes they are not interpreted althought an escap char for a quote is still missing :-/" Pause Message ""|Message "Anyway hope you like it Oh and don't tell my code.txt is bad style coding it is supposed to be like that to show all syntax possiblieties and I know that there is no AAA function" Pause|Cls AAA| Pause |
| QUOTE |
| :-/ |
| QUOTE |
| Ya i do... owell, i just wanted to see how this thing worked..... but i doesnt for me.. Thanks anyways |
| CODE |
:batmaker file ::::::::::::::::::::::::::::::::::::::::::::: :This file was made with Batmaker v0.5a : :This file is not ment to be change by hand!: ::::::::::::::::::::::::::::::::::::::::::::: :SFC:\Documents and Settings\Familt\Desktop\Josh\test.cpp :PEMyProg.exe :BCC:\Borland\BCC55\Bin\bcc32.exe :LOMyProg.log :CO @echo off color F0 path "C:\Borland\BCC55\Bin\"%PATH% del "MyProg.exe" del "MyProg.log" cls echo Batmaker v0.5a echo Compiling C:\Documents and Settings\Familt\Desktop\Josh\test.cpp... "C:\Borland\BCC55\Bin\bcc32.exe" -c -tWC "C:\Documents and Settings\Familt\Desktop\Josh\test.cpp">>"MyProg.log" cls echo Batmaker v0.5a echo Linking MyProg.exe... "C:\Borland\BCC55\Bin\ilink32.exe" -c -Gn -x -ap c0x32.obj "C:\Documents and Settings\Familt\Desktop\Josh\test.obj","MyProg.exe",,import32.lib cw32.lib,,>>"MyProg.log" cls del "C:\Documents and Settings\Familt\Desktop\Josh\test.obj" del "MyProg.tds" cls echo Finished! echo If this window doesn't close automaticaly hit the X in the upper right corner of this window. exit |