Parsley is a pattern matching and parsing tool for Python programmers.
Let's parse it up with Parsley. Following the standard example of other parsing frameworks, we're going to build a standard mathematical expression parser. Unlike other frameworks like PyParsing, Parsley grammars are defined in a giant string, rather than a special DSL.
Let's start with something that can interpret a collection of digits, and spit out a number:
import parsley
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sdl.h> | |
struct _EventFuncs { | |
void (*on_keydown) (char key, void *user_data); | |
void (*on_loop) (void *user_data); | |
}; | |
typedef struct _EventFuncs EventFucs; | |
void event_loop(EventFuncs *event_funcs, void *user_data) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FileName : array_v.h | |
// programmer bj streller and general folklore | |
// PURPOSE : Provides an extended definition of an Array ADT. | |
// We assume IndexType is a finite collection of consecutively | |
// enumerated values such as integers, characters, or enum values, | |
// and that BaseData is any type. | |
// Bounds checking via the assert macro is also done. |