waxeye-org / waxeye

Waxeye is a parser generator based on parsing expression grammars (PEGs). It supports C, Java, JavaScript, Python, Racket, and Ruby.
https://waxeye-org.github.io/waxeye/index.html
Other
235 stars 38 forks source link

Move C runtime to new parsing machine design #41

Open orlandohill opened 7 years ago

orlandohill commented 7 years ago

Based on the in-progress Java version? Also see the new JavaScript version.

glebm commented 7 years ago

Would be nice if the AST substrings are slices into the original string (char *, size_t), to improve memory-usage and performance.

orlandohill commented 7 years ago

Yes, makes sense.

Would the idea be to change AST_CHAR to AST_SPLICE, or to add AST_SPLICE as a new type? Something else entirely?

glebm commented 7 years ago

Yes, something like that.

Something like AST_CHARS, containing a string_view (naming matches C++ std::string_view, alternative name: chars_view):

typedef struct _string_view {
  // Does not own the pointer
  char *pointer;
  size_t size;
} string_view;

Ideas for naming:

The AST_CHAR type would then be removed.

orlandohill commented 7 years ago

Sounds good. AST_CHARS seems suitably short and descriptive.