Skip to content

Commit

Permalink
Redesign the project structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
uanhi committed Jul 30, 2021
1 parent 327b876 commit c8facc3
Show file tree
Hide file tree
Showing 64 changed files with 1,361 additions and 721 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.o
drift
drift.exe
.vscode
.idea
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
Copyright (C) 2021 bingxio

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

<program> Copyright (C) <year> <name of author>
drift Copyright (C) 2021 bingxio
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand Down
17 changes: 10 additions & 7 deletions README
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
Compiler front end of drift language.
The Drift Programming Language.

1. Written in pure C99 version.
2. A single compiled file compiles the source code into a bytecode file.
2. Bytecode execution.
3. For the drift language, see my blog post:
https://bingxio.fun/article/2021-05-24.html
4. The generated bytecode file runs on a virtual machine in any language.
5. Represents a runtime that can be used in other languages.
6. The compiler is only about 50 kb size and can only run on any device.
4. After optimization, the size is only about 15 kb.
5. The compiler runs on any device.
6. Provide external interfaces to access languages libraries
that support links.
7. Minimalist language implementation.

detail info:
- Front end of scripting language
- Scripting language
- Simplest implementation, programming language
- https://drift-lang.fun/
- Please refer to other warehouses in the team for details
Expand All @@ -18,7 +20,8 @@ license:
- GNU General Public License v3.0

build:
> gcc -std=gnu99 -Os compiler.c -o drift
My GCC version is 8.3.0 and Python 3
> python build.py
> ./drift

Have a good time! and give star if you like.
14 changes: 14 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# build.py
import os

list = []
for f in os.listdir():
if f.endswith('.c'):
list.append(f)
for i, v in enumerate(list):
print(i + 1, v)
os.system('gcc -std=gnu99 -c -Os %s' % v)
list[i] = v[0:len(v) - 2] + '.o'
os.system('gcc %s -o drift' % ' '.join(list))
os.system('rm -f *.o')
print('Done!', os.stat('drift').st_size / 1000, 'KB')
22 changes: 22 additions & 0 deletions code.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Drift
*
* - https://drift-lang.fun/
*
* GPL 3.0 License - bingxio <[email protected]> */
#ifndef FT_CODE_H
#define FT_CODE_H

#include "list.h"

/* Generate object, subject data type. */
typedef struct {
char *description; /* Description name */
list *names; /* Name set */
list *codes; /* Bytecode set */
list *offsets; /* Offset set */
list *types; /* Type set */
list *objects; /* Objects set */
list *lines; /* Lines set */
} code_object;

#endif
Loading

0 comments on commit c8facc3

Please sign in to comment.