Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

clean up cdescent.h

  • Loading branch information...
commit f75f7988ec91d4b2e772626094f5c65b55a51474 1 parent 8ac6651
@tj authored
Showing with 151 additions and 40 deletions.
  1. +151 −40 src/cdescent.h
View
191 src/cdescent.h
@@ -20,60 +20,171 @@
#define CDESCENT_VERSION "0.0.1"
-enum { Unknown= 0, Rule, Variable, Name, Dot, Character, String, Class, Action, Predicate, Alternate, Sequence, PeekFor, PeekNot, Query, Star, Plus };
+enum {
+ Unknown = 0
+ , Rule
+ , Variable
+ , Name
+ , Dot
+ , Character
+ , String
+ , Class
+ , Action
+ , Predicate
+ , Alternate
+ , Sequence
+ , PeekFor
+ , PeekNot
+ , Query
+ , Star
+ , Plus
+};
enum {
- RuleUsed = 1<<0,
- RuleReached = 1<<1,
+ RuleUsed = 0x1
+ , RuleReached = 0x2
};
typedef union Node Node;
-struct Rule { int type; Node *next; char *name; Node *variables; Node *expression; int id; int flags; };
-struct Variable { int type; Node *next; char *name; Node *value; int offset; };
-struct Name { int type; Node *next; Node *rule; Node *variable; };
-struct Dot { int type; Node *next; };
-struct Character { int type; Node *next; char *value; };
-struct String { int type; Node *next; char *value; };
-struct Class { int type; Node *next; unsigned char *value; };
-struct Action { int type; Node *next; char *text; Node *list; char *name; Node *rule; };
-struct Predicate { int type; Node *next; char *text; };
-struct Alternate { int type; Node *next; Node *first; Node *last; };
-struct Sequence { int type; Node *next; Node *first; Node *last; };
-struct PeekFor { int type; Node *next; Node *element; };
-struct PeekNot { int type; Node *next; Node *element; };
-struct Query { int type; Node *next; Node *element; };
-struct Star { int type; Node *next; Node *element; };
-struct Plus { int type; Node *next; Node *element; };
-struct Any { int type; Node *next; };
-
-union Node
-{
- int type;
- struct Rule rule;
+struct Rule {
+ int type;
+ Node *next;
+ char *name;
+ Node *variables;
+ Node *expression;
+ int id;
+ int flags;
+};
+
+struct Variable {
+ int type;
+ Node *next;
+ char *name;
+ Node *value;
+ int offset;
+};
+
+struct Name {
+ int type;
+ Node *next;
+ Node *rule;
+ Node *variable;
+};
+
+struct Dot {
+ int type;
+ Node *next;
+};
+
+struct Character {
+ int type;
+ Node *next;
+ char *value;
+};
+
+struct String {
+ int type;
+ Node *next;
+ char *value;
+};
+
+struct Class {
+ int type;
+ Node *next;
+ unsigned char *value;
+};
+
+struct Action {
+ int type;
+ Node *next;
+ char *text;
+ Node *list;
+ char *name;
+ Node *rule;
+};
+
+struct Predicate {
+ int type;
+ Node *next;
+ char *text;
+};
+
+struct Alternate {
+ int type;
+ Node *next;
+ Node *first;
+ Node *last;
+};
+
+struct Sequence {
+ int type;
+ Node *next;
+ Node *first;
+ Node *last;
+};
+
+struct PeekFor {
+ int type;
+ Node *next;
+ Node *element;
+};
+
+struct PeekNot {
+ int type;
+ Node *next;
+ Node *element;
+};
+
+struct Query {
+ int type;
+ Node *next;
+ Node *element;
+};
+
+struct Star {
+ int type;
+ Node *next;
+ Node *element;
+};
+
+struct Plus {
+ int type;
+ Node *next;
+ Node *element;
+};
+
+struct Any {
+ int type;
+ Node *next;
+};
+
+union Node {
+ int type;
+ struct Rule rule;
struct Variable variable;
- struct Name name;
- struct Dot dot;
- struct Character character;
- struct String string;
- struct Class cclass;
- struct Action action;
- struct Predicate predicate;
- struct Alternate alternate;
+ struct Name name;
+ struct Dot dot;
+ struct Character character;
+ struct String string;
+ struct Class cclass;
+ struct Action action;
+ struct Predicate predicate;
+ struct Alternate alternate;
struct Sequence sequence;
- struct PeekFor peekFor;
- struct PeekNot peekNot;
- struct Query query;
- struct Star star;
- struct Plus plus;
- struct Any any;
+ struct PeekFor peekFor;
+ struct PeekNot peekNot;
+ struct Query query;
+ struct Star star;
+ struct Plus plus;
+ struct Any any;
};
extern Node *actions;
extern Node *rules;
extern Node *start;
-extern int ruleCount;
+extern int ruleCount;
extern FILE *output;
Please sign in to comment.
Something went wrong with that request. Please try again.