@@ 30,7 30,7 @@
#include <string.h>
#define VERSION "1.1"
-#define BUFLEN 256
+#define BUFLEN 512
char *OPCODES[] = {"ADC", "AND", "ASL", "BCC", "BCS", "BEQ", "BIT", "BMI",
"BNE", "BPL", "BRK", "BVC", "BVS", "CLC", "CLD", "CLI",
@@ 202,6 202,9 @@ bool is_upper(char *str) {
bool is_label(char *line) {
int i, len = strlen(line);
for (i = 0; i < len; i++) {
+ if (line[i] == ' ' || line[i] == ';') {
+ return false;
+ }
if (line[i] == ':') {
return true;
}
@@ 275,10 278,8 @@ void lint(char *filepath, char *output, bool do_debug) {
set_line_key(trimed, key);
set_line_comment(trimed, comment);
if (!is_capital(key)) {
- printf("Error: Label %s is not capitalized, at %s:%d.\n", key, filepath,
+ printf("Lin6: Label %s not capitalized, at %s:%d.\n", key, filepath,
id);
- fclose(fr);
- exit(0);
}
if (key[0] != '@' && !skipped_last) {
strcat(output, "\n");
@@ 325,7 326,6 @@ void lint(char *filepath, char *output, bool do_debug) {
strcat(output, key);
strcat(output, " ");
if (has_comment(line)) {
- fillstr(value, 22, ' ');
strcat(output, value);
strcat(output, " ");
strcat(output, comment);
@@ 354,10 354,8 @@ void lint(char *filepath, char *output, bool do_debug) {
set_line_comment(trimed, comment);
fillstr(key, 24, ' ');
if (!is_lower(key)) {
- printf("Error: Variable %s is not lowercase, at %s:%d.\n", key,
- filepath, id);
- fclose(fr);
- exit(0);
+ printf("Lin6: Variable %s not lowercase, at %s:%d.\n", key, filepath,
+ id);
}
strcat(output, key);
strcat(output, value);
@@ 374,10 372,8 @@ void lint(char *filepath, char *output, bool do_debug) {
set_line_comment(trimed, comment);
fillstr(key, 20, ' ');
if (!is_upper(key)) {
- printf("Error: Constant %s is not uppercase, at %s:%d.\n", key,
- filepath, id);
- fclose(fr);
- exit(0);
+ printf("Lin6: Constant %s not uppercase, at %s:%d.\n", key, filepath,
+ id);
}
strcat(output, key);
strcat(output, value);
@@ 386,15 382,14 @@ void lint(char *filepath, char *output, bool do_debug) {
skipped_last = false;
constants++;
} else {
- printf("Error: Unknown line-type, at %s:%d.\n", filepath, id);
- fclose(fr);
- exit(0);
+ printf("Lin6: Unknown line-type, at %s:%d.\n", filepath, id);
+ strcat(output, line);
}
strcat(output, "\n");
count++;
}
if (do_debug) {
- printf("Linted %d lines: \n", count);
+ printf("Lin6 debug: %d lines: \n", count);
printf("\t%d labels\n", labels);
printf("\t%d opcodes\n", opcodes);
printf("\t%d directives\n", directives);
@@ 442,9 437,9 @@ int main(int argc, char *argv[]) {
}
/* do files */
else {
- char linted[32768];
+ char linted[51200];
if (!file_exists(argv[i])) {
- printf("Error! File %s not found\n", argv[i]);
+ printf("Lin6: File %s not found\n", argv[i]);
exit(0);
}
lint(argv[i], linted, do_debug);