Преглед на файлове

split tibasic.h -> log.hh, token_util.hh + migrate *.cpp to .cc + migrate *.h to .hh (when c++ only code) + update README

Noah Vogt преди 3 години
родител
ревизия
8ee9d0702c
променени са 9 файла, в които са добавени 55 реда и са изтрити 59 реда
  1. 3 3
      Makefile
  2. 9 4
      README.md
  3. 3 2
      src/compiler.cc
  4. 0 0
      src/compiler.hh
  5. 0 23
      src/log.hh
  6. 4 2
      src/main.cc
  7. 24 1
      src/token_list.h
  8. 1 3
      src/token_util.cc
  9. 11 21
      src/token_util.hh

+ 3 - 3
Makefile

@@ -7,9 +7,9 @@ VERSION = 0.1
 PREFIX = /usr
 
 PROJDIRS := src
-SRCFILES := $(shell find $(PROJDIRS) -type f -name "*.cpp")
-OBJFILES := $(patsubst %.cpp,%.o,$(SRCFILES))
-DEPFILES := $(patsubst %.cpp,%.d,$(SRCFILES))
+SRCFILES := $(shell find $(PROJDIRS) -type f -name "*.cc")
+OBJFILES := $(patsubst %.cc,%.o,$(SRCFILES))
+DEPFILES := $(patsubst %.cc,%.d,$(SRCFILES))
 
 .PHONY: all clean
 

+ 9 - 4
README.md

@@ -1,13 +1,13 @@
-# The TI-BASIC Compiler (tibasicc)
-The TI-BASIC Compiler is all about compiling TI-BASIC code on your computer into an .8xp file ready for transferring to your TI-83/TI-83+/TI-84 calculator (and vice versa).
+# tibasicc
+a (de-)compiler for TI-BASIC with comment support
 
-Being able to type your programs on a real keyboard instead of the calculator's keypad is much easier and avoids some otherwise big pain.
+This little program is all about compiling TI-BASIC code on your computer into an .8xp file ready for transferring to your TI-83/TI-83+/TI-84 calculator (and vice versa). Being able to type your programs on a real keyboard instead of the calculator's keypad is much easier and avoids some otherwise big pain.
 
 *Note:* This project is a fork from [pcmattman/tibasic](https://sourceforge.net/projects/tibasic/).
 
 ## Installation
 #### Unix (GNU/Linux, MacOS, FreeBSD, etc.)
-If you are using Arch, you can just install my [AUR Package](https://aur.archlinux.org/packages/tibasicc-git/) either with your prefered aur helper (paru, yay, etc.) or manually:
+If you are using Arch, you can just install my [AUR Package](https://aur.archlinux.org/packages/tibasicc-git/) either [manually](https://wiki.archlinux.org/title/Arch_User_Repository#Installing_and_upgrading_packages) or with your prefered aur helper (paru, yay, etc.):
 
     paru -S tibasicc-git
 
@@ -47,3 +47,8 @@ Preprocessor
 Additional Options
 - verbose / debug mode that gives a lot of information (`-v` flag)
 - specify output file (`-o` flag)
+
+## Possible Future Features / TODO's
+- add a 'check' make target
+- add bash / zsh autocompletion
+- update / add documentation

+ 3 - 2
src/compiler.cpp → src/compiler.cc

@@ -22,8 +22,9 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "tibasic.h"
-#include "compiler.h"
+#include "token_util.hh"
+#include "log.hh"
+#include "compiler.hh"
 
 using namespace std;
 

+ 0 - 0
src/compiler.h → src/compiler.hh


+ 0 - 23
src/tibasic.h → src/log.hh

@@ -15,17 +15,6 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#ifndef _TIBASIC_H
-#define _TIBASIC_H
-
-#include <string>
-
-/* Stores a token to be written and the size of that token. */
-typedef struct {
-    unsigned short token;
-    size_t sz;
-} token_t;
-
 /* Log severities */
 enum LogSeverity {
     Error,
@@ -33,15 +22,6 @@ enum LogSeverity {
     Debug
 };
 
-void stripExtension(const char *in, char *out, size_t len);
-
-void initialiseTokens();
-
-size_t getLongestToken();
-
-bool lookupToken(std::string in, token_t &ret);
-bool lookupToken(unsigned short in, std::string &out);
-
 inline const char *severityToString(LogSeverity s) {
     switch(s) {
         case Error:
@@ -61,6 +41,3 @@ inline const char *severityToString(LogSeverity s) {
 
 /* Log function */
 void log(LogSeverity, const char *);
-
-
-#endif

+ 4 - 2
src/main.cpp → src/main.cc

@@ -19,11 +19,13 @@
 #include <string>
 #include <string.h>
 
-#include "tibasic.h"
 #ifdef _WIN32
 #include "Shlwapi.h"
 #endif
-#include "compiler.h"
+
+#include "log.hh"
+#include "token_util.hh"
+#include "compiler.hh"
 
 using namespace std;
 

+ 24 - 1
src/token_list.h

@@ -15,7 +15,30 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include "token_util.h"
+/* Describes a potential token to be read by the compiler */
+struct Token {
+    /* The compiled byte for the token */
+	unsigned char data;
+
+    /* The actual text to be converted by the interpreter */
+	const char* text;
+};
+
+/* A two byte token (0xBB, 0x7E and SysVar) */
+struct TwoByte {
+	unsigned short data;
+	const char* text;
+};
+
+/* Direct ASCII character to token conversion. */
+struct ConvertRule {
+	char c;				/* the character */
+	unsigned char tok;	/* the equivalent token */
+};
+
+extern struct Token StandardTokens[200];
+extern struct TwoByte CalcVars[302];
+extern struct ConvertRule Replacements[39];
 
 /* Token List */
 #define TO_DMS			0x01

+ 1 - 3
src/token_util.cpp → src/token_util.cc

@@ -19,7 +19,7 @@
 #include <string>
 #include <string.h>
 
-#include "tibasic.h"
+#include "token_util.hh"
 #include "token_list.h"
 
 using namespace std;
@@ -109,5 +109,3 @@ bool lookupToken(unsigned short in, string &out) {
 
     return true;
 }
-
-

+ 11 - 21
src/token_util.h → src/token_util.hh

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (c) 2021 Noah Vogt <noah@noahvogt.com>
  * Copyright (c) 2011 Matthew Iselin
  *
@@ -15,27 +15,17 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* Describes a potential token to be read by the compiler */
-struct Token {
-    /* The compiled byte for the token */
-	unsigned char data;
+#include <string>
 
-    /* The actual text to be converted by the interpreter */
-	const char* text;
-};
+/* Stores a token to be written and the size of that token. */
+typedef struct {
+    unsigned short token;
+    size_t sz;
+} token_t;
 
-/* A two byte token (0xBB, 0x7E and SysVar) */
-struct TwoByte {
-	unsigned short data;
-	const char* text;
-};
+void initialiseTokens();
 
-/* Direct ASCII character to token conversion. */
-struct ConvertRule {
-	char c;				/* the character */
-	unsigned char tok;	/* the equivalent token */
-};
+size_t getLongestToken();
 
-extern struct Token StandardTokens[200];
-extern struct TwoByte CalcVars[302];
-extern struct ConvertRule Replacements[39];
+bool lookupToken(std::string in, token_t &ret);
+bool lookupToken(unsigned short in, std::string &out);