Skip to content

Commit

Permalink
🔥 big update
Browse files Browse the repository at this point in the history
  • Loading branch information
fennecdjay committed Dec 29, 2024
1 parent de0b705 commit d545490
Show file tree
Hide file tree
Showing 15 changed files with 2,229 additions and 2,149 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ include/parser.h src/parser.c: src/gwion.y

clean:
$(info cleaning)
@rm -f src/*.o *.a src/*.gcno src/*.gcda
@rm -f build/*.o *.a src/*.gcno src/*.gcda
@rm -f grammar/*.o tool/*.o

install: translation-install libgwion_ast.a
Expand Down
1 change: 0 additions & 1 deletion include/absyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ typedef struct Stmt_Try_ {
} * Stmt_Try;

enum ae_pp_type {
ae_pp_comment,
ae_pp_include,
ae_pp_define,
ae_pp_pragma,
Expand Down
22 changes: 19 additions & 3 deletions include/ast_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@
#ifndef __AST_GETTER
#define __AST_GETTER

struct AstGetter_ {
const m_str name;
typedef enum {
comment_normal,
comment_after,
comment_before,
} comment_t;
typedef struct Comment {
m_str str;
loc_t loc;
comment_t type;
bool alone;
} Comment;
MK_VECTOR_TYPE(Comment, comment)


typedef struct AstGetter_ {
const char *name;
FILE * f;
SymTable * st;
PPArg *ppa;
};
CommentList **comments;
bool fmt;
} AstGetter;

ANN Ast parse_pos(struct AstGetter_ *const, const pos_t);
ANN static inline Ast parse(struct AstGetter_ *const arg) {
Expand Down
2 changes: 1 addition & 1 deletion include/gwion_ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "macro.h"
#include "pparg.h"
#include "pp.h"
#include "scanner.h"
#include "ast_getter.h"
#include "scanner.h"
#include "ast_pass.h"
#endif
2 changes: 1 addition & 1 deletion include/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ extern int yylex \
#undef yyTABLES_NAME
#endif

#line 446 "src/gwion.l"
#line 450 "src/gwion.l"


#line 723 "include/lexer.h"
Expand Down
232 changes: 115 additions & 117 deletions include/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,64 +121,63 @@ extern int gwion_debug;
CHAR_LIT = 323, /* "<litteral char>" */
INTERP_START = 324, /* "${" */
INTERP_EXP = 325, /* INTERP_EXP */
PP_COMMENT = 326, /* "<comment>" */
PP_INCLUDE = 327, /* "#include" */
PP_DEFINE = 328, /* "#define" */
PP_PRAGMA = 329, /* "#pragma" */
PP_UNDEF = 330, /* "#undef" */
PP_IFDEF = 331, /* "#ifdef" */
PP_IFNDEF = 332, /* "#ifndef" */
PP_ELSE = 333, /* "#else" */
PP_ENDIF = 334, /* "#if" */
PP_NL = 335, /* "\n" */
SPREAD = 336, /* "}..." */
INTERP_LIT = 337, /* "<interp string lit>" */
INTERP_END = 338, /* "<interp string end>" */
ID = 340, /* "<identifier>" */
PLUS = 341, /* "+" */
PLUSPLUS = 342, /* "++" */
MINUS = 343, /* "-" */
MINUSMINUS = 344, /* "--" */
TIMES = 345, /* "*" */
DIVIDE = 346, /* "/" */
PERCENT = 347, /* "%" */
DOLLAR = 348, /* "$" */
QUESTION = 349, /* "?" */
OPTIONS = 350, /* OPTIONS */
COLON = 351, /* ":" */
COLONCOLON = 352, /* "::" */
QUESTIONCOLON = 353, /* "?:" */
NEW = 354, /* "new" */
SPORK = 355, /* "spork" */
FORK = 356, /* "fork" */
L_HACK = 357, /* "<<<" */
R_HACK = 358, /* ">>>" */
AND = 359, /* "&&" */
EQ = 360, /* "==" */
GE = 361, /* ">=" */
GT = 362, /* ">" */
LE = 363, /* "<=" */
LT = 364, /* "<" */
NEQ = 365, /* "!=" */
SHIFT_LEFT = 366, /* "<<" */
SHIFT_RIGHT = 367, /* ">>" */
S_AND = 368, /* "&" */
S_OR = 369, /* "|" */
S_XOR = 370, /* "^" */
OR = 371, /* "||" */
TMPL = 372, /* ":[" */
TILDA = 373, /* "~" */
EXCLAMATION = 374, /* "!" */
AROBASE = 375, /* "@" */
DYNOP = 376, /* "<dynamic_operator>" */
LOCALE_EXP = 377, /* "`foo`" */
RANGE_EMPTY = 378, /* RANGE_EMPTY */
UMINUS = 379, /* UMINUS */
UTIMES = 380, /* UTIMES */
SECTION_LIST = 381, /* SECTION_LIST */
STMT_LIST3 = 382, /* STMT_LIST3 */
STMT_LIST2 = 383, /* STMT_LIST2 */
STMT_LIST1 = 384 /* STMT_LIST1 */
PP_INCLUDE = 326, /* "#include" */
PP_DEFINE = 327, /* "#define" */
PP_PRAGMA = 328, /* "#pragma" */
PP_UNDEF = 329, /* "#undef" */
PP_IFDEF = 330, /* "#ifdef" */
PP_IFNDEF = 331, /* "#ifndef" */
PP_ELSE = 332, /* "#else" */
PP_ENDIF = 333, /* "#if" */
PP_NL = 334, /* "\n" */
SPREAD = 335, /* "}..." */
INTERP_LIT = 336, /* "<interp string lit>" */
INTERP_END = 337, /* "<interp string end>" */
ID = 339, /* "<identifier>" */
PLUS = 340, /* "+" */
PLUSPLUS = 341, /* "++" */
MINUS = 342, /* "-" */
MINUSMINUS = 343, /* "--" */
TIMES = 344, /* "*" */
DIVIDE = 345, /* "/" */
PERCENT = 346, /* "%" */
DOLLAR = 347, /* "$" */
QUESTION = 348, /* "?" */
OPTIONS = 349, /* OPTIONS */
COLON = 350, /* ":" */
COLONCOLON = 351, /* "::" */
QUESTIONCOLON = 352, /* "?:" */
NEW = 353, /* "new" */
SPORK = 354, /* "spork" */
FORK = 355, /* "fork" */
L_HACK = 356, /* "<<<" */
R_HACK = 357, /* ">>>" */
AND = 358, /* "&&" */
EQ = 359, /* "==" */
GE = 360, /* ">=" */
GT = 361, /* ">" */
LE = 362, /* "<=" */
LT = 363, /* "<" */
NEQ = 364, /* "!=" */
SHIFT_LEFT = 365, /* "<<" */
SHIFT_RIGHT = 366, /* ">>" */
S_AND = 367, /* "&" */
S_OR = 368, /* "|" */
S_XOR = 369, /* "^" */
OR = 370, /* "||" */
TMPL = 371, /* ":[" */
TILDA = 372, /* "~" */
EXCLAMATION = 373, /* "!" */
AROBASE = 374, /* "@" */
DYNOP = 375, /* "<dynamic_operator>" */
LOCALE_EXP = 376, /* "`foo`" */
RANGE_EMPTY = 377, /* RANGE_EMPTY */
UMINUS = 378, /* UMINUS */
UTIMES = 379, /* UTIMES */
SECTION_LIST = 380, /* SECTION_LIST */
STMT_LIST3 = 381, /* STMT_LIST3 */
STMT_LIST2 = 382, /* STMT_LIST2 */
STMT_LIST1 = 383 /* STMT_LIST1 */
};
typedef enum yytokentype yytoken_kind_t;
#endif
Expand Down Expand Up @@ -254,64 +253,63 @@ extern int gwion_debug;
#define CHAR_LIT 323
#define INTERP_START 324
#define INTERP_EXP 325
#define PP_COMMENT 326
#define PP_INCLUDE 327
#define PP_DEFINE 328
#define PP_PRAGMA 329
#define PP_UNDEF 330
#define PP_IFDEF 331
#define PP_IFNDEF 332
#define PP_ELSE 333
#define PP_ENDIF 334
#define PP_NL 335
#define SPREAD 336
#define INTERP_LIT 337
#define INTERP_END 338
#define ID 340
#define PLUS 341
#define PLUSPLUS 342
#define MINUS 343
#define MINUSMINUS 344
#define TIMES 345
#define DIVIDE 346
#define PERCENT 347
#define DOLLAR 348
#define QUESTION 349
#define OPTIONS 350
#define COLON 351
#define COLONCOLON 352
#define QUESTIONCOLON 353
#define NEW 354
#define SPORK 355
#define FORK 356
#define L_HACK 357
#define R_HACK 358
#define AND 359
#define EQ 360
#define GE 361
#define GT 362
#define LE 363
#define LT 364
#define NEQ 365
#define SHIFT_LEFT 366
#define SHIFT_RIGHT 367
#define S_AND 368
#define S_OR 369
#define S_XOR 370
#define OR 371
#define TMPL 372
#define TILDA 373
#define EXCLAMATION 374
#define AROBASE 375
#define DYNOP 376
#define LOCALE_EXP 377
#define RANGE_EMPTY 378
#define UMINUS 379
#define UTIMES 380
#define SECTION_LIST 381
#define STMT_LIST3 382
#define STMT_LIST2 383
#define STMT_LIST1 384
#define PP_INCLUDE 326
#define PP_DEFINE 327
#define PP_PRAGMA 328
#define PP_UNDEF 329
#define PP_IFDEF 330
#define PP_IFNDEF 331
#define PP_ELSE 332
#define PP_ENDIF 333
#define PP_NL 334
#define SPREAD 335
#define INTERP_LIT 336
#define INTERP_END 337
#define ID 339
#define PLUS 340
#define PLUSPLUS 341
#define MINUS 342
#define MINUSMINUS 343
#define TIMES 344
#define DIVIDE 345
#define PERCENT 346
#define DOLLAR 347
#define QUESTION 348
#define OPTIONS 349
#define COLON 350
#define COLONCOLON 351
#define QUESTIONCOLON 352
#define NEW 353
#define SPORK 354
#define FORK 355
#define L_HACK 356
#define R_HACK 357
#define AND 358
#define EQ 359
#define GE 360
#define GT 361
#define LE 362
#define LT 363
#define NEQ 364
#define SHIFT_LEFT 365
#define SHIFT_RIGHT 366
#define S_AND 367
#define S_OR 368
#define S_XOR 369
#define OR 370
#define TMPL 371
#define TILDA 372
#define EXCLAMATION 373
#define AROBASE 374
#define DYNOP 375
#define LOCALE_EXP 376
#define RANGE_EMPTY 377
#define UMINUS 378
#define UTIMES 379
#define SECTION_LIST 380
#define STMT_LIST3 381
#define STMT_LIST2 382
#define STMT_LIST1 383

/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
Expand Down Expand Up @@ -372,7 +370,7 @@ union YYSTYPE
Prim_Def prim_def;
Ast ast;

#line 376 "include/parser.h"
#line 374 "include/parser.h"

};
typedef union YYSTYPE YYSTYPE;
Expand Down
6 changes: 3 additions & 3 deletions include/pp.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ typedef struct PPState_ {
MacroArg arg;
void * data;
};
m_str filename;
char* filename;
loc_t loc;
enum pptype type;
} PPState;
Expand All @@ -32,7 +32,7 @@ typedef struct PP_ {
int npar;
} PP;

ANN PPState *new_ppstate(MemPool, const m_str);
ANEW PP *new_pp(MemPool p, const uint size, const m_str);
ANN PPState *new_ppstate(MemPool, const char *name);
ANEW PP *new_pp(MemPool p, const uint size, const char *name);
ANN void free_pp(MemPool p, PP *pp, void *data);
#endif
1 change: 0 additions & 1 deletion include/pparg.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ typedef struct PPArg_ {
struct Vector_ path;
struct Hash_ hash;
Ast ast;
bool fmt;
} PPArg;

ANN void pparg_ini(MemPool, PPArg *);
Expand Down
2 changes: 1 addition & 1 deletion include/scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ typedef struct Scanner_ {
void * scanner;
SymTable * st;
struct PP_ * pp;
PPArg *ppa;
AstGetter *getter;
struct Vector_ hashes;
struct pos_t pos;
struct pos_t tmp;
Expand Down
Loading

0 comments on commit d545490

Please sign in to comment.