]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
added beginnings of pratt parser
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 2 Apr 2019 03:23:23 +0000 (23:23 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 2 Apr 2019 03:23:23 +0000 (23:23 -0400)
src/parser.c

index 0e9e50d9e876ff9e160d2510d2bcb66a2a5e4437..034ea291c12ea8ef90023953e6a27941880f973f 100644 (file)
@@ -28,6 +28,51 @@ static int Indent = 0;
 #define parse_exit()
 #endif
 
+typedef struct {
+    int precedence;
+    int token;
+    AST* (*parse)(Parser* p, AST* expr);
+} OpDef_T;
+
+AST* if_expr(Parser* p, AST* expr);
+AST* block_expr(Parser* p, AST* expr);
+AST* paren_expr(Parser* p, AST* expr);
+AST* binop_expr(Parser* p, AST* expr);
+AST* fncall_expr(Parser* p, AST* expr);
+
+OpDef_T PrefixOps[] = {
+    { 0, T_IF, if_expr    }, /* If expression */
+    { 0, '{',  block_expr }, /* Expression block */
+    { 0, '(',  paren_expr }, /* Parenthese grouping */
+};
+
+OpDef_T InfixOps[] = {
+    { 0, '.', binop_expr  }, /* If expression */
+    { 0, '(', fncall_expr }, /* Parenthese grouping */
+};
+
+/* Operator Parsing Routines
+ *****************************************************************************/
+AST* if_expr(Parser* p, AST* expr) {
+    return NULL;
+}
+
+AST* block_expr(Parser* p, AST* expr) {
+    return NULL;
+}
+
+AST* paren_expr(Parser* p, AST* expr) {
+    return NULL;
+}
+
+AST* binop_expr(Parser* p, AST* expr) {
+    return NULL;
+}
+
+AST* fncall_expr(Parser* p, AST* expr) {
+    return NULL;
+}
+
 /* Parsing Routines
  *****************************************************************************/
 static Tok* peek(Parser* p) {