HOME
|
GIT
|
CV
|
MUSINGS
LOG
|
FILES
|
OVERVIEW
F diff --git a/all.h b/all.h
--- a/all.h
+++ b/all.h
- #include "all.h"
#include "ast.h"
#include "denoted.h"
#include "lexer.h"
#include "semantics.h"
#include "type.h"
+ #include "queue.h"
+ #include "map.h"
+ #include "stack.h"
- #include "ast.c"
- #include "chonky.c"
- #include "chonky_jr.c"
- #include "compile.c"
- #include "context.c" //delete
- #include "denoted.c"
- #include "lexer.c"
- #include "location.c"
- #include "map.c"
- #include "parse.c"
- #include "parse_declaration.c"
- #include "parse_expression.c"
- #include "parse_statement.c"
- #include "parse_translation_unit.c"
- #include "preprocessing.c"
- #include "print.c"
- #include "program.c"
- #include "queue.c"
- #include "scope.c"
- #include "semantics.c"
- #include "stack.c"
- #include "type.c"
-
+ #include "print.h"
#endif
F diff --git a/ast.h b/ast.h
--- a/ast.h
+++ b/ast.h
#ifndef GCC_AST_H
#define GCC_AST_H GCC_AST_H
+ #include "ast.hh"
#include "scope.h"
#include "parse_declaration.h"
#include "denoted.h"
- struct Denoted;
-
- enum AST_Type{
- OP_COMMA
- ,OP_ADDITION,OP_SUBTRACTION,OP_MUL,OP_DIV,OP_REMAINDER
- ,OP_COND,OP_FUNCTION
- ,OP_ASSIGN,OP_ADD_ASSIGN,OP_SUBTRACT_ASSIGN,OP_MULTIPLY_ASSIGN,OP_REMAINDER_ASSIGN,OP_DIV_ASSIGN
- ,OP_SHIFT_LEFT_ASSIGN,OP_SHIFT_RIGHT_ASSIGN
- ,OP_AND_ASSIGN,OP_XOR_ASSIGN,OP_PIPE_ASSIGN
- ,OP_NOP
- ,OP_LOGICAL_OR,OP_LOGICAL_AND,OP_LOGICAL_NOT
- ,OP_BITWISE_OR,OP_BITWISE_AND,OP_BITWISE_XOR,OP_BITWISE_NOT
- ,OP_ADDR_OF,OP_DEREFERENCE,OP_MEMBER_TROUGH_PTR,OP_MEMBER,OP_ARR_SUBSCRIPT
- ,OP_POSTFIX_INC,OP_POSTFIX_DEC
- ,OP_PREFIX_INC,OP_PREFIX_DEC
- ,OP_UNARY_PLUS,OP_UNARY_MINUS
- ,OP_CAST,OP_SIZEOF
- ,OP_SHIFT_LEFT,OP_SHIFT_RIGHT
- ,OP_LESS_EQ,OP_GREATER_EQ
- ,OP_LESS,OP_GREATER
- ,OP_EQUAL,OP_NOT_EQUAL
- ,OP_LVALUE,OP_RVALUE
- ,ST_COMPOUND,ST_EXPRESSION,ST_SWITCH,ST_IF,ST_WHILE,ST_DO_WHILE,ST_GOTO,ST_LABEL,ST_CASE,ST_DEFAULT
- ,ST_CONTINUE,ST_BREAK,ST_RETURN,ST_FOR
- ,ST_OBJECT_DECLARATION,ST_TYPE_DEFINITION,ST_FUNCTION_DEFINITION
- ,ST_FUNCTION_DECLARATION
- ,TRANSLATION_UNIT
- ,ERROR,ERROR_DECLARATION
- };
+ enum AST_Type;
F diff --git a/ast.hh b/ast.hh
new file mode 100644
--- /dev/null
+++ b/ast.hh
+ #ifndef GCC_AST_HH
+ #define GCC_AST_HH GCC_AST_HH
+
+ enum AST_Type{
+ OP_COMMA
+ ,OP_ADDITION,OP_SUBTRACTION,OP_MUL,OP_DIV,OP_REMAINDER
+ ,OP_COND,OP_FUNCTION
+ ,OP_ASSIGN,OP_ADD_ASSIGN,OP_SUBTRACT_ASSIGN,OP_MULTIPLY_ASSIGN,OP_REMAINDER_ASSIGN,OP_DIV_ASSIGN
+ ,OP_SHIFT_LEFT_ASSIGN,OP_SHIFT_RIGHT_ASSIGN
+ ,OP_AND_ASSIGN,OP_XOR_ASSIGN,OP_PIPE_ASSIGN
+ ,OP_NOP
+ ,OP_LOGICAL_OR,OP_LOGICAL_AND,OP_LOGICAL_NOT
+ ,OP_BITWISE_OR,OP_BITWISE_AND,OP_BITWISE_XOR,OP_BITWISE_NOT
+ ,OP_ADDR_OF,OP_DEREFERENCE,OP_MEMBER_TROUGH_PTR,OP_MEMBER,OP_ARR_SUBSCRIPT
+ ,OP_POSTFIX_INC,OP_POSTFIX_DEC
+ ,OP_PREFIX_INC,OP_PREFIX_DEC
+ ,OP_UNARY_PLUS,OP_UNARY_MINUS
+ ,OP_CAST,OP_SIZEOF
+ ,OP_SHIFT_LEFT,OP_SHIFT_RIGHT
+ ,OP_LESS_EQ,OP_GREATER_EQ
+ ,OP_LESS,OP_GREATER
+ ,OP_EQUAL,OP_NOT_EQUAL
+ ,OP_LVALUE,OP_RVALUE
+ ,ST_COMPOUND,ST_EXPRESSION,ST_SWITCH,ST_IF,ST_WHILE,ST_DO_WHILE,ST_GOTO,ST_LABEL,ST_CASE,ST_DEFAULT
+ ,ST_CONTINUE,ST_BREAK,ST_RETURN,ST_FOR
+ ,ST_OBJECT_DECLARATION,ST_TYPE_DEFINITION,ST_FUNCTION_DEFINITION
+ ,ST_FUNCTION_DECLARATION
+ ,TRANSLATION_UNIT
+ ,ERROR,ERROR_DECLARATION
+ };
+ struct AST;
+ struct AST_Error;
+ struct AST_Declaration_Error;
+ struct AST_Binary_Expression;
+ struct AST_Conditional_Expression;
+ struct AST_Function_Expression;
+ struct AST_Rvalue_Expression;
+ struct AST_Lvalue_Expression;
+ struct AST_Unary_Expression;
+ struct AST_Labeled_Statement;
+ struct AST_Compound_Statement;
+ struct AST_For_Statement;
+ struct AST_While_Statement;
+ struct AST_Do_While_Statement;
+ struct AST_If_Statement;
+ struct AST_Goto_Statement;
+ struct AST_Switch_Statement;
+ struct AST_Return_Statement;
+ struct AST_Type_Definition;
+ struct AST_Object_Declaration;
+ struct AST_Function_Definition;
+ struct AST_Function_Declaration;
+ struct AST_Translation_Unit;
+
+ #endif
F diff --git a/ast.o b/ast.o
new file mode 100644
B Binary files /dev/null and b/ast.o differ
F diff --git a/chonky.c b/chonky.c
--- a/chonky.c
+++ b/chonky.c
#ifndef GKEYWORDS_MENU_C
#define GKEYWORDS_MENU_C GKEYWORDS_MENU_C
+ #include"chonky.h"
+ #include<stddef.h>
int cmpr[256]={0,0,0,0,0,0,0,0,0,57,57,57,0,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,29,30,31,0,32,33,34,37,38,41,42,44,43,45,46,28,28,28,28,28,28,28,28,28,28,47,48,49,51,50,52,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,39,53,40,54,55,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,35,56,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};
int uncmpr[256]={0,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,57,33,34,35,37,38,39,123,125,40,41,91,93,42,43,45,44,46,47,58,59,60,62,61,63,92,94,95,124,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};
- enum KEYWORDS{KW_AUTO,KW_DO,KW_DOUBLE,KW_INT,KW_STRUCT,KW_BREAK,KW_ELSE,KW_LONG,KW_SWITCH,KW_CASE,KW_ENUM,KW_REGISTER,KW_TYPEDEF,KW_CHAR,KW_EXTERN,KW_RETURN,KW_UNION,KW_CONST,KW_FLOAT,KW_SHORT,KW_UNSIGNED,KW_CONTINUE,KW_FOR,KW_SIGNED,KW_VOID,KW_DEFAULT,KW_GOTO,KW_SIZEOF,KW_VOLATILE,KW_IF,KW_STATIC,KW_WHILE,KW_EXCLAMATION,KW_BACK_SLASH,KW_PERCENT,KW_AND,KW_AND_AND,KW_QUOTE,KW_OPEN_NORMAL,KW_CLOSE_NORMAL,KW_STAR,KW_PLUS,KW_COMMA,KW_MINUS,KW_DOT,KW_ARROW,KW_COLUMN,KW_SEMI_COLUMN,KW_LESS,KW_EQ,KW_EQEQ,KW_MORE,KW_QUESTION,KW_OPEN_SQUARE,KW_CLOSE_SQUARE,KW_HAT,KW_FLOOR,KW_OPEN_CURLY,KW_CLOSE_CURLY,KW_PIPE,KW_PIPE_PIPE,KW_TILDE,KW_PLUSPLUS,KW_MINUSMINUS,KW_SHIFT_RIGHT,KW_SHIFT_LEFT,KW_LESS_EQ,KW_MORE_EQ,KW_NOT_EQ,KW_PLUS_EQ,KW_MINUS_EQ,KW_STAR_EQ,KW_PERCENT_EQ,KW_SHIFT_LEFT_EQ,KW_SHIFT_RIGHT_EQ,KW_AND_EQ,KW_HAT_EQ,KW_PIPE_EQ,KW_DIV_EQ,KW_FORWARD_SLASH,KW_NOTYPE,KW_NUMBER,KW_COMMENT,KW_ID,KW_STRING,PKW_IF,PKW_INCLUDE,PKW_DEFINE,PKW_UNDEF,PKW_PRAGMA,PKW_ENDIF,PKW_IFNDEF,PKW_IFDEF,PKW_ELIF,PKW_ERROR,PKW_COMMENT,PKW_NOTYPE};
-
-
- struct automata_entry
- {
- unsigned char is_final;
- enum KEYWORDS type;
- struct automata_entry* delta[58];
- };
-
-
struct automata_entry chonky[]={
-
{0,KW_NOTYPE,{NULL,&(chonky[2]),&(chonky[10]),&(chonky[11]),&(chonky[12]),&(chonky[13]),&(chonky[14]),&(chonky[15]),&(chonky[16]),&(chonky[2]),&(chonky[17]),&(chonky[2]),&(chonky[2]),&(chonky[18]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[19]),&(chonky[20]),&(chonky[21]),&(chonky[22]),&(chonky[23]),&(chonky[24]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[1]),&(chonky[25]),&(chonky[3]),NULL,&(chonky[26]),&(chonky[27]),&(chonky[28]),&(chonky[29]),&(chonky[30]),&(chonky[31]),&(chonky[32]),&(chonky[33]),&(chonky[34]),&(chonky[35]),&(chonky[36]),&(chonky[37]),&(chonky[38]),&(chonky[39]),&(chonky[5]),&(chonky[40]),&(chonky[41]),&(chonky[42]),&(chonky[43]),&(chonky[44]),&(chonky[45]),&(chonky[46]),&(chonky[47]),&(chonky[48]),&(chonky[49]),NULL,} },
{1,KW_NUMBER,{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,&(chonky[1]),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,} },
{1,KW_ID,{NULL,&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),&(chonky[2]),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,&(chonky[2]),NULL,NULL,} },
F diff --git a/chonky.h b/chonky.h
new file mode 100644
--- /dev/null
+++ b/chonky.h
+ #ifndef GKEYWORDS_MENU_H
+ #define GKEYWORDS_MENU_H GKEYWORDS_MENU_H
+ #include <stddef.h>
+
+
+
+ enum KEYWORDS{KW_AUTO,KW_DO,KW_DOUBLE,KW_INT,KW_STRUCT,KW_BREAK,KW_ELSE,KW_LONG,KW_SWITCH,KW_CASE,KW_ENUM,KW_REGISTER,KW_TYPEDEF,KW_CHAR,KW_EXTERN,KW_RETURN,KW_UNION,KW_CONST,KW_FLOAT,KW_SHORT,KW_UNSIGNED,KW_CONTINUE,KW_FOR,KW_SIGNED,KW_VOID,KW_DEFAULT,KW_GOTO,KW_SIZEOF,KW_VOLATILE,KW_IF,KW_STATIC,KW_WHILE,KW_EXCLAMATION,KW_BACK_SLASH,KW_PERCENT,KW_AND,KW_AND_AND,KW_QUOTE,KW_OPEN_NORMAL,KW_CLOSE_NORMAL,KW_STAR,KW_PLUS,KW_COMMA,KW_MINUS,KW_DOT,KW_ARROW,KW_COLUMN,KW_SEMI_COLUMN,KW_LESS,KW_EQ,KW_EQEQ,KW_MORE,KW_QUESTION,KW_OPEN_SQUARE,KW_CLOSE_SQUARE,KW_HAT,KW_FLOOR,KW_OPEN_CURLY,KW_CLOSE_CURLY,KW_PIPE,KW_PIPE_PIPE,KW_TILDE,KW_PLUSPLUS,KW_MINUSMINUS,KW_SHIFT_RIGHT,KW_SHIFT_LEFT,KW_LESS_EQ,KW_MORE_EQ,KW_NOT_EQ,KW_PLUS_EQ,KW_MINUS_EQ,KW_STAR_EQ,KW_PERCENT_EQ,KW_SHIFT_LEFT_EQ,KW_SHIFT_RIGHT_EQ,KW_AND_EQ,KW_HAT_EQ,KW_PIPE_EQ,KW_DIV_EQ,KW_FORWARD_SLASH,KW_NOTYPE,KW_NUMBER,KW_COMMENT,KW_ID,KW_STRING,PKW_IF,PKW_INCLUDE,PKW_DEFINE,PKW_UNDEF,PKW_PRAGMA,PKW_ENDIF,PKW_IFNDEF,PKW_IFDEF,PKW_ELIF,PKW_ERROR,PKW_COMMENT,PKW_NOTYPE};
+
+
+ struct automata_entry
+ {
+ unsigned char is_final;
+ enum KEYWORDS type;
+ struct automata_entry* delta[58];
+ };
+ extern struct automata_entry chonky[];
+ extern int cmpr[256];
+ extern int uncmpr[256];
+
+ #endif
F diff --git a/chonky.o b/chonky.o
new file mode 100644
B Binary files /dev/null and b/chonky.o differ
F diff --git a/chonky_jr.c b/chonky_jr.c
--- a/chonky_jr.c
+++ b/chonky_jr.c
#ifndef GPREPROCESSING_KEYWORDS_MENU_C
#define GPREPROCESSING_KEYWORDS_MENU_C GPREPROCESSING_KEYWORDS_MENU_C
- #include"chonky.c"
+ #include"chonky.h"
+ #include "chonky_jr.h"
struct automata_entry chonky_jr[]={
F diff --git a/chonky_jr.h b/chonky_jr.h
new file mode 100644
--- /dev/null
+++ b/chonky_jr.h
+ #ifndef GPREPROCESSING_KEYWORDS_MENU_H
+ #define GPREPROCESSING_KEYWORDS_MENU_H GPREPROCESSING_KEYWORDS_MENU_H
+ #include "chonky_jr.h"
+
+
+ extern struct automata_entry chonky_jr[];
+
+
+ #endif
F diff --git a/chonky_jr.o b/chonky_jr.o
new file mode 100644
B Binary files /dev/null and b/chonky_jr.o differ
F diff --git a/compile.c b/compile.c
deleted file mode 100644
--- a/compile.c
+++ /dev/null
- #ifndef GCC_COMPILE_C
- #define GCC_COMPILE_C GCC_COMPILE_C
-
- #endif
F diff --git a/context.c b/context.c
deleted file mode 100644
--- a/context.c
+++ /dev/null
- #ifndef GCC_CONTEXT
- #define GCC_CONTEXT GCC_CONTEXT
- #include"map.c"
- #include<assert.h>
-
-
-
- #endif
F diff --git a/denoted.c b/denoted.c
--- a/denoted.c
+++ b/denoted.c
#define GCC_DENOTED_C GCC_DENOTED_C
#include "denoted.h"
-
struct Denoted* get_denoted_error(struct Denoted *error)
{
struct Denoted_Error *ret;
F diff --git a/denoted.h b/denoted.h
--- a/denoted.h
+++ b/denoted.h
#ifndef GCC_DENOTED_H
#define GCC_DENOTED_H GCC_DENOTED_H
+ #include "denoted.hh"
#include "type.h"
- #include "ast.h"
+ #include "scope.h"
+ #include "semantics.h"
+
+
+ enum Denotation_Type;
+ enum Function_Specifier;
+ enum Storage_Class;
- enum Denotation_Type
- {
- DT_Macro,
- DT_Macro_Parameter,
- DT_Label,
- DT_Object,
- DT_Typedef,
- DT_Function,
- DT_Enum,
- DT_Enum_Constant,
- DT_Struct_Union_Member,
- DT_Struct_Union_Tag,
- DT_Error,
- DT_Prototype
- };
- enum Function_Specifier
- {
- FS_Inline,
- FS_None
- };
- enum Storage_Class
- {
- SC_EXTERN,
- SC_STATIC,
- SC_TYPEDEF,
- SC_NONE
- };
struct Denoted
{
enum Denotation_Type denotation;
enum Storage_Class storage_class;
};
+
+
+
struct Denoted* get_denoted_error(struct Denoted *error);
struct Denoted* get_denoted_function(struct token *id,struct Type *return_type,enum Function_Specifier fs);
struct Denoted* get_denoted_object(struct token *id, enum Storage_Class sc,struct Type *type);
F diff --git a/denoted.hh b/denoted.hh
new file mode 100644
--- /dev/null
+++ b/denoted.hh
+ #ifndef GCC_DENOTED_HH
+ #define GCC_DENOTED_HH GCC_DENOTED_HH
+
+
+ enum Denotation_Type
+ {
+ DT_Macro,
+ DT_Macro_Parameter,
+ DT_Label,
+ DT_Object,
+ DT_Typedef,
+ DT_Function,
+ DT_Enum,
+ DT_Enum_Constant,
+ DT_Struct_Union_Member,
+ DT_Struct_Union_Tag,
+ DT_Error,
+ DT_Prototype
+ };
+
+ enum Function_Specifier
+ {
+ FS_Inline,
+ FS_None
+ };
+ enum Storage_Class
+ {
+ SC_EXTERN,
+ SC_STATIC,
+ SC_TYPEDEF,
+ SC_NONE
+ };
+
+ struct Denoted;
+ struct Denoted_Error;
+ struct Denoted_Base;
+ struct Denoted_Function;
+ struct Denoted_Object;
+ struct Denoted_Typedef;
+ struct Denoted_Enum;
+ struct Denoted_Enum_Const;
+ struct Denoted_Struct_Union;
+ struct Denotation_Prototype;
+ struct Object;
+
+
+ #endif
F diff --git a/denoted.o b/denoted.o
new file mode 100644
B Binary files /dev/null and b/denoted.o differ
F diff --git a/lexer.c b/lexer.c
--- a/lexer.c
+++ b/lexer.c
#define LEXER_C LEXER_C
#include "lexer.h"
-
-
struct Queue* lex(struct Source_File *src,struct Program *prog)
{
F diff --git a/lexer.h b/lexer.h
--- a/lexer.h
+++ b/lexer.h
#ifndef LEXER_H
#define LEXER_H LEXER_H
+ #include "lexer.hh"
#include<stdio.h>
- #include"chonky.c"
- #include"chonky_jr.c"
- #include"queue.c"
+ #include "chonky.h"
+ #include "chonky_jr.h"
+ #include "queue.h"
#include "program.h"
-
struct token
{
enum KEYWORDS type;
struct token **argument_list;
};
+
+
+
struct Queue* lex(struct Source_File *src,struct Program *prog);
struct token* get_next_token(struct Source_File *src,struct Program *prog,struct automata_entry *start_state);
struct token_vector Lex_Queue_Condense(struct Queue *tokens);
F diff --git a/lexer.hh b/lexer.hh
new file mode 100644
--- /dev/null
+++ b/lexer.hh
+ #ifndef LEXER_HH
+ #define LEXER_HH LEXER_HH
+
+ /*struct declarations. Definitions are in .h*/
+ struct token;
+ struct token_vector;
+ struct define_directive;
+
+ #endif
F diff --git a/lexer.o b/lexer.o
new file mode 100644
B Binary files /dev/null and b/lexer.o differ
F diff --git a/location.h b/location.h
--- a/location.h
+++ b/location.h
#ifndef GCC_LOCATION_H
#define GCC_LOCATION_H GCC_LOCATION_H
+ #include "location.hh"
+ #include "lexer.h"
+ #include "type.h"
- enum Location_Type
- {
- LT_ON_STACK,
- LT_RAW,
- LT_RELATIVE,
- LT_LABELED,
- LT_GLOBAL
- };
+
+ enum Location_Type;
struct Location
{
enum Location_Type type;
F diff --git a/location.hh b/location.hh
new file mode 100644
--- /dev/null
+++ b/location.hh
+ #ifndef GCC_LOCATION_HH
+ #define GCC_LOCATION_HH GCC_LOCATION_HH
+ enum Location_Type
+ {
+ LT_ON_STACK,
+ LT_RAW,
+ LT_RELATIVE,
+ LT_LABELED,
+ LT_GLOBAL
+ };
+ struct Location;
+ struct Location_Stack;
+ struct Location_Raw;
+ struct Location_Relative;
+ struct Location_Labeled;
+
+ #endif
F diff --git a/location.o b/location.o
new file mode 100644
B Binary files /dev/null and b/location.o differ
F diff --git a/main.o b/main.o
new file mode 100644
B Binary files /dev/null and b/main.o differ
F diff --git a/makefile b/makefile
--- a/makefile
+++ b/makefile
- install:
- gcc -g main.c -o main.exe
+ install: ast.o chonky.o chonky_jr.o denoted.o lexer.o location.o map.o parse_declaration.o parse_expression.o parse_statement.o parse_translation_unit.o preprocessing.o print.o program.o queue.o scope.o semantics.o stack.o type.o main.o
+ gcc -g *.o -o wonky
run: install
./main.exe
+
+ main.o: main.c
+ gcc -c main.c -o main.o
+ ast.o: ast.c ast.h
+ gcc -c ast.c -o ast.o
+ chonky.o: chonky.c
+ gcc -c chonky.c -o chonky.o
+ chonky_jr.o: chonky_jr.c
+ gcc -c chonky_jr.c -o chonky_jr.o
+ denoted.o: denoted.c denoted.h
+ gcc -c denoted.c -o denoted.o
+ lexer.o: lexer.c lexer.h
+ gcc -c lexer.c -o lexer.o
+ location.o: location.c location.h
+ gcc -c location.c -o location.o
+ parse_declaration.o: parse_declaration.c parse_declaration.h
+ gcc -c parse_declaration.c -o parse_declaration.o
+ parse_expression.o: parse_expression.c parse_expression.h
+ gcc -c parse_expression.c -o parse_expression.o
+ parse_statement.o: parse_statement.c parse_statement.h
+ gcc -c parse_statement.c -o parse_statement.o
+ parse_translation_unit.o: parse_translation_unit.c parse_translation_unit.h
+ gcc -c parse_translation_unit.c -o parse_translation_unit.o
+ preprocessing.o: preprocessing.c preprocessing.h
+ gcc -c preprocessing.c -o preprocessing.o
+ print.o: print.c print.h
+ gcc -c print.c -o print.o
+ program.o: program.c program.h
+ gcc -c program.c -o program.o
+ scope.o: scope.c scope.h
+ gcc -c scope.c -o scope.o
+ semantics.o: semantics.c semantics.h
+ gcc -c semantics.c -o semantics.o
+ test2.o: test2.c test2.h
+ gcc -c test2.c -o test2.o
+ test.o: test.c test.h
+ gcc -c test.c -o test.o
+ type.o: type.c type.h
+ gcc -c type.c -o type.o
+ map.o: map.c map.h
+ gcc -c map.c -o map.o
+ queue.o: queue.c queue.h
+ gcc -c queue.c -o queue.o
+ stack.o: stack.c stack.h
+ gcc -c stack.c -o stack.o
+
clear:
- rm ./*.exe &
- rm ./*.temp &
- rm ./*.out
+ rm ./*.exe -f &
+ rm ./*.temp -f &
+ rm ./*.o -f &
+ rm ./*.out -f
debug:
gcc -g main.c
gdbtui a.out
F diff --git a/map.c b/map.c
--- a/map.c
+++ b/map.c
- #ifndef GMAP
- #define GMAP GMAP
- #include<stdlib.h>
- #include<stdio.h>
- #include"stack.c"
- #include"queue.c"
- //#include"../Queue/unique_queue.c"
+ #ifndef GMAP_C
+ #define GMAP_C GMAP_C
+ #include "map.h"
- typedef struct Map Map;
-
-
- void Map_Init(Map *tree);
- void Map_Scour(Map *tree,void *str,size_t size,size_t *where,Map **final_node);
- void Map_Push(Map *tree,void *str,size_t size,void *id);
- void* Map_Check(Map *tree, void *str,size_t size);
- void Map_Remove(Map *tree, void *str,size_t size);
- void Map_Map(Map *tree,void (*map)(void*));
- void Map_Destroy(Map *tree);
- struct Condensed_Map* Map_Condense(Map* tree);
-
-
- /*
- * A looples automata with things attached to the nodes
- * */
- struct Map
- {
- char is_final;
- Map *delta[256];
- /*ID cannot point to itself ( this is used in the deletion of the map ) */
- void *ID; //I have integer ids in mind but can be a translation for exmpl.
- };
-
/*
* ID and residue and all of delta is assigned to NULL
F diff --git a/map.h b/map.h
new file mode 100644
--- /dev/null
+++ b/map.h
+ #ifndef GMAP_H
+ #define GMAP_H GMAP_H
+ #include<stdlib.h>
+ #include<stdio.h>
+ #include"stack.h"
+ #include"queue.h"
+ //#include"../Queue/unique_queue.c"
+
+ typedef struct Map Map;
+
+
+
+ /*
+ * A looples automata with things attached to the nodes
+ * */
+ struct Map
+ {
+ char is_final;
+ Map *delta[256];
+ /*ID cannot point to itself ( this is used in the deletion of the map ) */
+ void *ID; //I have integer ids in mind but can be a translation for exmpl.
+ };
+
+ void Map_Init(Map *tree);
+ void Map_Scour(Map *tree,void *str,size_t size,size_t *where,Map **final_node);
+ void Map_Push(Map *tree,void *str,size_t size,void *id);
+ void* Map_Check(Map *tree, void *str,size_t size);
+ void Map_Remove(Map *tree, void *str,size_t size);
+ void Map_Map(Map *tree,void (*map)(void*));
+ void Map_Destroy(Map *tree);
+ struct Condensed_Map* Map_Condense(Map* tree);
+ #endif
F diff --git a/map.o b/map.o
new file mode 100644
B Binary files /dev/null and b/map.o differ
F diff --git a/parse.c b/parse.c
deleted file mode 100644
--- a/parse.c
+++ /dev/null
- #ifndef GCC_PARSE_C
- #define GCC_PARSE_C GCC_PARSE_C
-
- #include "parse_expression.h"
- #include "parse_statement.h"
- #include "parse_declaration.h"
- #include "parse_translation_unit.h"
-
-
- #include "parse_expression.c"
- #include "parse_statement.c"
- #include "parse_declaration.c"
- #include "parse_translation_unit.c"
-
-
-
-
- #endif
F diff --git a/parse.h b/parse.h
new file mode 100644
--- /dev/null
+++ b/parse.h
+ #ifndef GCC_PARSE_C
+ #define GCC_PARSE_C GCC_PARSE_C
+
+ #include "parse_expression.h"
+ #include "parse_statement.h"
+ #include "parse_declaration.h"
+ #include "parse_translation_unit.h"
+
+
+ #include "parse_expression.c"
+ #include "parse_statement.c"
+ #include "parse_declaration.c"
+ #include "parse_translation_unit.c"
+
+
+
+
+ #endif
F diff --git a/parse_declaration.h b/parse_declaration.h
--- a/parse_declaration.h
+++ b/parse_declaration.h
#define GCC_PARSE_DECLARATION_H GCC_PARSE_DECLARATION_H
#include "ast.h"
#include "parse_expression.h"
+ #include "parse_statement.h"
#include "type.h"
#include "denoted.h"
#include "scope.h"
- #include "queue.c"
- #include "map.c"
+ #include "queue.h"
+ #include "map.h"
#include "lexer.h"
#include <assert.h>
struct Denotation_Prototype;
struct Struct_Union;
struct Denoted_Object;
+ struct Enum;
void parse_declaration(struct Queue *tokens,struct Scope *scope,struct Queue *where_to_push,char parse_function_definitions);
F diff --git a/parse_declaration.o b/parse_declaration.o
new file mode 100644
B Binary files /dev/null and b/parse_declaration.o differ
F diff --git a/parse_expression.h b/parse_expression.h
--- a/parse_expression.h
+++ b/parse_expression.h
#ifndef GCC_PARSE_EXPR_H
#define GCC_PARSE_EXPR_H GCC_PARSE_EXPR_H
- #include"chonky.c"
- #include"queue.c"
+ #include"chonky.h"
+ #include"queue.h"
#include"lexer.h"
#include"parse_declaration.h"
#include"ast.h"
F diff --git a/parse_expression.o b/parse_expression.o
new file mode 100644
B Binary files /dev/null and b/parse_expression.o differ
F diff --git a/parse_statement.h b/parse_statement.h
--- a/parse_statement.h
+++ b/parse_statement.h
#ifndef PARSE_GCC_STATEMENT_H
#define PARSE_GCC_STATEMENT_H PARSE_GCC_STATEMENT_H
- #include"lexer.c"
- #include"ast.h"
- #include "scope.h"
- #include"parse_expression.h"
+ #include "all.h"
+ struct Queue;
+ struct Scope;
+ enum AST_Type;
struct AST* parse_finish_compound_statement(struct Queue* tokens,struct Scope *scope);
struct AST* parse_op_e_cl_st(struct Queue* tokens,struct Scope *scope);
F diff --git a/parse_statement.o b/parse_statement.o
new file mode 100644
B Binary files /dev/null and b/parse_statement.o differ
F diff --git a/parse_translation_unit.o b/parse_translation_unit.o
new file mode 100644
B Binary files /dev/null and b/parse_translation_unit.o differ
F diff --git a/preprocessing.o b/preprocessing.o
new file mode 100644
B Binary files /dev/null and b/preprocessing.o differ
F diff --git a/print.o b/print.o
new file mode 100644
B Binary files /dev/null and b/print.o differ
F diff --git a/program.h b/program.h
--- a/program.h
+++ b/program.h
#ifndef GCC_PROGRAM_H
#define GCC_PROGRAM_H GCC_PROGRAM_H
- #include "queue.c"
+ #include "program.hh"
+ #include "queue.h"
#include "scope.h"
#include "lexer.h"
F diff --git a/program.hh b/program.hh
new file mode 100644
--- /dev/null
+++ b/program.hh
+ #ifndef GCC_PROGRAM_HH
+ #define GCC_PROGRAM_HH GCC_PROGRAM_HH
+
+ struct Source_File;
+ struct Program;
+
+
+ #endif
F diff --git a/program.o b/program.o
new file mode 100644
B Binary files /dev/null and b/program.o differ
F diff --git a/queue.c b/queue.c
--- a/queue.c
+++ b/queue.c
#ifndef GQUEUE_C
#define GQUEUE_C GQUEUE_C
- #include<stdlib.h>//malloc free
- #include<assert.h>
-
- typedef struct Queue Queue;
-
- struct Queue
- {
- struct Queue_Node
- {
- void *data;
- struct Queue_Node *prev;
- }*first,*last;
-
- size_t size;
-
- };
+ #include "queue.h"
void Queue_Init(Queue *q)
{
F diff --git a/queue.h b/queue.h
new file mode 100644
--- /dev/null
+++ b/queue.h
+ #ifndef GQUEUE_H
+ #define GQUEUE_H GQUEUE_H
+ #include<stdlib.h>//malloc free
+ #include<assert.h>
+
+ typedef struct Queue Queue;
+
+ struct Queue
+ {
+ struct Queue_Node
+ {
+ void *data;
+ struct Queue_Node *prev;
+ }*first,*last;
+
+ size_t size;
+
+ };
+ void Queue_Init(Queue *q);
+ void Queue_Push(Queue *q,void *data);
+ void Queue_Push_Front(struct Queue *q,void *data);
+ void* Queue_Pop(Queue *q);
+ void Queue_Append(struct Queue *lead,struct Queue *follower);
+ void Queue_Destroy(Queue *q);
+
+ #endif
F diff --git a/queue.o b/queue.o
new file mode 100644
B Binary files /dev/null and b/queue.o differ
F diff --git a/scope.h b/scope.h
--- a/scope.h
+++ b/scope.h
#ifndef GCC_SCOPE_H
#define GCC_SCOPE_H GCC_SCOPE_H
- #include "map.c"
+ #include "scope.hh"
+ #include "map.h"
#include "denoted.h"
#include "location.h"
F diff --git a/scope.hh b/scope.hh
new file mode 100644
--- /dev/null
+++ b/scope.hh
+ #ifndef GCC_SCOPE_HH
+ #define GCC_SCOPE_HH GCC_SCOPE_HH
+
+ struct Scope;
+
+ #endif
F diff --git a/scope.o b/scope.o
new file mode 100644
B Binary files /dev/null and b/scope.o differ
F diff --git a/semantics.c b/semantics.c
--- a/semantics.c
+++ b/semantics.c
#ifndef GCC_SEMANTICS_C
#define GCC_SEMANTICS_C GCC_SEMANTICS_C
+ #include"semantics.h"
F diff --git a/semantics.h b/semantics.h
--- a/semantics.h
+++ b/semantics.h
#ifndef GCC_SEMANTICS_H
#define GCC_SEMANTICS_H GCC_SEMANTICS_H
- #include "semantics.h"
+ #include "ast.h"
+ #include "lexer.h"
long long int evaluate_const_expression_integer(struct AST *expression);
long long int evaluate_literal_integer_dec(struct token *token);
F diff --git a/semantics.o b/semantics.o
new file mode 100644
B Binary files /dev/null and b/semantics.o differ
F diff --git a/stack.c b/stack.c
--- a/stack.c
+++ b/stack.c
#ifndef GSTACK_C
#define GSTACK_C GSTACK_C
- #include<stdlib.h>//malloc free et alii
+ #include "stack.h"
- typedef struct Stack Stack;
-
- struct Stack
- {
- struct Stack_Node
- {
- struct Stack_Node *next;
- void *data;
- }*first;
- size_t size;
- };
void Stack_Init(Stack *stack)
{
F diff --git a/stack.h b/stack.h
new file mode 100644
--- /dev/null
+++ b/stack.h
+ #ifndef GSTACK_H
+ #define GSTACK_H GSTACK_H
+ #include<stdlib.h>//malloc free et alii
+ typedef struct Stack Stack;
+
+ struct Stack
+ {
+ struct Stack_Node
+ {
+ struct Stack_Node *next;
+ void *data;
+ }*first;
+ size_t size;
+ };
+
+ void Stack_Init(Stack *stack);
+ void Stack_Push(Stack *stack,void* data);
+ void* Stack_Pop(Stack *stack);
+
+
+ #endif
F diff --git a/stack.o b/stack.o
new file mode 100644
B Binary files /dev/null and b/stack.o differ
F diff --git a/type.h b/type.h
--- a/type.h
+++ b/type.h
#ifndef GCC_TYPE_H
#define GCC_TYPE_H GCC_TYPE_H
+ #include "type.hh"
#include "denoted.h"
#include "scope.h"
#include <limits.h>
- //typedef void ;
- struct Denotation_Prototype;
- /*this isn't just type-specifier*/
- enum Type_Specifier
- {
- TS_VOID,
- TS_CHAR,
- TS_INT,
- TS_FLOAT,
- TS_DOUBLE,
- TS_STRUCT,
- TS_ENUM,
- TS_UNION,
- TS_POINTER,
- TS_ARRAY,
- TS_FUNC,
- TS_BITFIELD,
- TS_NONE,
- TS_ERROR
- };
- enum Type_Constraint
- {
- TC_LONG,
- TC_LONG_LONG,
- TC_SHORT,
- TC_NONE
- };
- enum Type_Signedness
- {
- TSIGN_SIGNED,
- TSIGN_UNSIGNED,
- TSIGN_NONE
- };
+ enum Type_Specifier;
+ enum Type_Constraint;
+ enum Type_Signedness;
struct Type
{
F diff --git a/type.hh b/type.hh
new file mode 100644
--- /dev/null
+++ b/type.hh
+ #ifndef GCC_TYPE_HH
+ #define GCC_TYPE_HH GCC_TYPE_HH
+
+
+ /*this isn't just type-specifier :DD*/
+ enum Type_Specifier
+ {
+ TS_VOID,
+ TS_CHAR,
+ TS_INT,
+ TS_FLOAT,
+ TS_DOUBLE,
+ TS_STRUCT,
+ TS_ENUM,
+ TS_UNION,
+ TS_POINTER,
+ TS_ARRAY,
+ TS_FUNC,
+ TS_BITFIELD,
+ TS_NONE,
+ TS_ERROR
+ };
+ enum Type_Constraint
+ {
+ TC_LONG,
+ TC_LONG_LONG,
+ TC_SHORT,
+ TC_NONE
+ };
+ enum Type_Signedness
+ {
+ TSIGN_SIGNED,
+ TSIGN_UNSIGNED,
+ TSIGN_NONE
+ };
+ struct Type;
+ struct Type_Error;
+ struct Type_Struct_Union;
+ struct Struct_Union;
+ struct Type_Bit_Field;
+ struct Type_Basic;
+ struct Type_Pointer;
+ struct Type_Array;
+ struct Type_Function;
+ struct Type_Enum;
+ struct Enum;
+ #endif
F diff --git a/type.o b/type.o
new file mode 100644
B Binary files /dev/null and b/type.o differ
F diff --git a/wonky b/wonky
new file mode 100755
B Binary files /dev/null and b/wonky differ