Pages: [1]
  Print  
Author Topic: Screw it  (Read 2197 times)
Offline (Male) Josh @ Dreamland
Posted on: July 13, 2012, 11:22:32 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2955

View Profile Email
As I announced on the IRC, I resolved several issues with the parser and now the entirety of the STL will "parse" — "parse," in the sense that the parser successfully makes it from one end of the file to another without crashing, burning, or leaking. On that note, I have decided that the parser will be plugged into ENIGMA "as-is," in an effort to get the system working on new Linux distributions (and apparently on really new Windows systems).

This will begin tomorrow, after I make a few more attempts at correcting the existing errors.

In case you are worried, let me elaborate on the status of the parser. Its C support is flawless—I do not own a C header that it has, in testing, not successfully completed. It is easily capable enough to define all of ENIGMA's functions, types, and globals.

Code: [Select]
> d
Enter the item to define:
>> sin
double sin(double __x);
> d
Enter the item to define:
>> strstr
char *strstr(char *__haystack, const char *__needle);
> d
Enter the item to define:
>> malloc
void *malloc(size_t __size);
> d
Enter the item to define:
>> sprintf
int sprintf(char *__s, const char *__format, ...);
> d
Enter the item to define:
>> fwrite
size_t fwrite(const void *__ptr, size_t __size, size_t __n, FILE *__s);


The parser does NOT have what it takes to give complicated template definitions. It has a good start, but nothing more. Its typename keyword handling is entirely broken because I was foolish enough to believe that I could handle partial specializations inline; I need to lex the shit and handle it at instantiation time. Also, it actually lacks support for overloading  cast operators and operators (), [], new, delete, new[], and delete[]. Those are simple things I might fix before plugging it in.

Code: [Select]
> d
Enter the item to define:
>> std::vector
No `vector' found in scope `std'
> d
Enter the item to define:
>> std::string
typedef basic_string string;
> d
Enter the item to define:
>> std::basic_string
template<typename _CharT, typename _Traits = char_traits, typename _Alloc = allocator> class basic_string;
> d
Enter the item to define:
>> std::map
template<typename _Key, typename _Tp, typename _Compare = less, typename _Alloc = allocator> class map
{
  value_compare _Alloc;
  typedef value_type _Alloc_value_type;
  value_compare _Compare;
  value_compare _Key;
  value_compare _Tp;
  typedef _Alloc allocator_type;
  typedef _Compare key_compare;
  typedef _Key key_type;
  typedef _Tp mapped_type;
  class value_comparepublic binary_function
  {
  }
  typedef pair value_type;
}

You may gather that it has no definition for vector, or for string, save that it's a typedef of some basic_string instance; that basic_string is abstract, and that map is missing some three dozen members. This is probably related to the 6600 errors that are thrown as those headers parse. Probably.

Don't fret, though; that's a good thing. When I said "this parser won't break every time a new GCC is released," I said that seriously; not because this parser is perfect, but because this parser can take a beating. A huge beating.

For those who are interested in the actual error count, it was 6625.
http://dl.dropbox.com/u/1052740/enigma/demos/JDI/valgrind-2012-07-14.txt

The only worry I have right now—the above considered—is its performance on windows, where each console print costs 25 milliseconds. I'll probably have to pass in a custom error handler that doesn't print anything. No biggie, theoretically. I also need to get its file reading mechanism working on Windows.

Damn, I hate Windows.
« Last Edit: July 15, 2012, 12:11:15 PM by IsmAvatar » Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) TheExDeus
Reply #1 Posted on: July 14, 2012, 04:23:37 AM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
I love windows (well.. maybe only a little).

GML and in extent EDL is basically C anyway. There is a reason why instances are int and this int is passed to other functions (i.e. not inst.point_distance(x,y) but point_distance(inst.x,inst.y,x,y)). So if basic things work (together with arrays which apparently doesn't?) then its good to go. The current parser has problems with varargs in scripts, script arguments in with(){} and the lack of way to declare global arrays (global var array[]) among other things. So I pray that this mostly works as intended.
Logged
Offline (Male) Josh @ Dreamland
Reply #2 Posted on: July 14, 2012, 09:53:52 AM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2955

View Profile Email
As I said, at present, I'm just replacing the C parser, not the GML parser, until the lion's share of the C++ issues are resolved. Otherwise, we'd just be taking a step sideways.

JDI doesn't have issue with anything C; that includes arrays. So don't worry about that.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Pages: [1]
  Print