summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/convert.c2
-rw-r--r--src/core/convert.h2
-rw-r--r--src/core/function.c2
-rw-r--r--src/core/function.h2
-rw-r--r--src/core/garbage.c2
-rw-r--r--src/core/garbage.h2
-rw-r--r--src/core/interpret.c2
-rw-r--r--src/core/interpret.h2
-rw-r--r--src/core/scanner.c110
-rw-r--r--src/core/scanner.h5
-rw-r--r--src/core/scope.c2
-rw-r--r--src/core/scope.h2
-rw-r--r--src/core/symbol.c2
-rw-r--r--src/core/symbol.h2
-rw-r--r--src/core/token.c2
-rw-r--r--src/core/token.h2
16 files changed, 64 insertions, 79 deletions
diff --git a/src/core/convert.c b/src/core/convert.c
index bddbf1e..ff0fcb2 100644
--- a/src/core/convert.c
+++ b/src/core/convert.c
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/convert.h b/src/core/convert.h
index fc7f3bd..632283e 100644
--- a/src/core/convert.h
+++ b/src/core/convert.h
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/function.c b/src/core/function.c
index 134024b..4225309 100644
--- a/src/core/function.c
+++ b/src/core/function.c
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/function.h b/src/core/function.h
index 024b05a..e7cfe48 100644
--- a/src/core/function.h
+++ b/src/core/function.h
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/garbage.c b/src/core/garbage.c
index ec01dc6..3d39d71 100644
--- a/src/core/garbage.c
+++ b/src/core/garbage.c
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/garbage.h b/src/core/garbage.h
index 522bdd8..d7f6609 100644
--- a/src/core/garbage.h
+++ b/src/core/garbage.h
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/interpret.c b/src/core/interpret.c
index 4eb26b1..340b80a 100644
--- a/src/core/interpret.c
+++ b/src/core/interpret.c
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/interpret.h b/src/core/interpret.h
index 5f9e6d2..743a24a 100644
--- a/src/core/interpret.h
+++ b/src/core/interpret.h
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/scanner.c b/src/core/scanner.c
index 7159881..a202bc3 100644
--- a/src/core/scanner.c
+++ b/src/core/scanner.c
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
@@ -37,45 +37,10 @@
#include <ctype.h>
#include <string.h>
-const char const *KEYWORDS[] = {
- "if",
- "else",
- "elsif",
- "while",
- "ret",
- "const",
-};
-
-const char const *OPERATORS[] = {
- "!",
- "!=",
- "(",
- ")",
- "*",
- "+",
- "++",
- ",",
- "-",
- "--",
- ".",
- "/",
- "\\",
- ":",
- "==",
- ";",
- "<<",
- "<",
- "<=",
- "=",
- ">=",
- ">>",
- ">",
- "{",
- "}",
-};
-
-const char TOKENENDS[] = "{}();:,.";
-int CODESTRING_INDEX = 0;
+const char const *_TOKENENDS2[] = { "==", "!=", "<=", ">=", };
+const char _TOKENENDS[] = "})+-*/={(<>;:,.!";
+#define _ADD_SEMICOLON_INDEX 2
+int _CODESTR_INDEX = 0;
Scanner*
scanner_new(List *p_list_token, Tupel *p_tupel_argv) {
@@ -105,9 +70,8 @@ scanner_new(List *p_list_token, Tupel *p_tupel_argv) {
p_scanner->i_current_line_nr = 1;
p_scanner->i_current_pos_nr = 0;
- p_scanner->i_num_keywords = sizeof(KEYWORDS) / sizeof(char const *);
- p_scanner->i_num_operators = sizeof(OPERATORS) / sizeof(char const *);
- p_scanner->i_num_tokenends = strlen(TOKENENDS);
+ p_scanner->i_num_tokenends2 = sizeof(_TOKENENDS2) / sizeof(char const *);
+ p_scanner->i_num_tokenends = strlen(_TOKENENDS);
return p_scanner;
}
@@ -120,6 +84,15 @@ scanner_delete(Scanner *p_scanner) {
}
void
+_add_semicolon_to_list(Scanner *p_scanner) {
+ int i_token_len = 1;
+ char *c_token = calloc(2, sizeof(char*));
+ c_token[0] = ';';
+ c_token[1] = '\0';
+ scanner_add_token(p_scanner, &c_token, &i_token_len, TT_SEMICOLON);
+}
+
+void
scanner_post_task(Scanner *p_scanner) {
List *p_list_token = scanner_get_list_token(p_scanner);
ListIterator *p_iter = listiterator_new(p_list_token);
@@ -157,7 +130,7 @@ scanner_post_task(Scanner *p_scanner) {
pt_last[0] = pt_last[1] = NULL;
tt_last[0] = tt_last[1] = TT_NONE;
- }
+ }
}
tt_last[0] = tt_last[1];
@@ -175,7 +148,7 @@ _scanner_has_next_char(Scanner *p_scanner) {
if (p_scanner->fp)
return !feof(p_scanner->fp);
- return p_scanner->c_codestring[CODESTRING_INDEX] != 0;
+ return p_scanner->c_codestring[_CODESTR_INDEX] != 0;
}
char
@@ -183,7 +156,7 @@ _scanner_get_next_char(Scanner *p_scanner) {
if (p_scanner->fp)
return fgetc(p_scanner->fp);
- return (p_scanner->c_codestring[CODESTRING_INDEX++]);
+ return (p_scanner->c_codestring[_CODESTR_INDEX++]);
}
void
@@ -196,7 +169,6 @@ scanner_run(Fype *p_fype) {
c_token[0] = 0;
while ( _scanner_has_next_char(p_scanner) ) {
- //char c = fgetc(fp);
char c = _scanner_get_next_char(p_scanner);
++p_scanner->i_current_pos_nr;
@@ -238,8 +210,8 @@ scanner_run(Fype *p_fype) {
}
{
int i_num_nl = 0;
+ _Bool flag = false;
do {
- // c = fgetc(fp);
c = _scanner_get_next_char(p_scanner);
if ( c == '\n' ) {
++i_num_nl;
@@ -252,11 +224,13 @@ scanner_run(Fype *p_fype) {
c_token[i_token_len] = 0;
} else if (c == '"') {
- if (i_token_len && c_token[i_token_len-1] == '\\')
+ if (i_token_len && c_token[i_token_len-1] == '\\') {
c_token[i_token_len-1] = '"';
- else
+ } else {
+ flag = true;
break;
+ }
} else {
++i_token_len;
@@ -265,13 +239,15 @@ scanner_run(Fype *p_fype) {
c_token[i_token_len] = 0;
}
- //} while ( !feof(fp) );
} while ( _scanner_has_next_char(p_scanner) );
scanner_add_token(p_scanner, &c_token, &i_token_len, TT_STRING);
if (i_num_nl)
p_scanner->i_current_line_nr += i_num_nl;
+
+ if (flag)
+ _add_semicolon_to_list(p_scanner);
}
break;
@@ -301,10 +277,23 @@ scanner_run(Fype *p_fype) {
scanner_add_token(p_scanner, &c_token, &i_token_len, tt_cur);
} else {
+ for (int i = 0; i < p_scanner->i_num_tokenends2; ++i) {
+ if (_TOKENENDS2[i][0] == c) {
+ /*
+ TokenType tt_cur = scanner_get_tt_cur(c_token);
+ scanner_add_token(p_scanner, &c_token, &i_token_len, tt_cur);
+ if (i < _ADD_SEMICOLON_INDEX)
+ _add_semicolon_to_list(p_scanner);
+ break;
+ */
+ }
+ }
for (int i = 0; i < p_scanner->i_num_tokenends; ++i) {
- if (TOKENENDS[i] == c) {
+ if (_TOKENENDS[i] == c) {
TokenType tt_cur = scanner_get_tt_cur(c_token);
- scanner_add_token(p_scanner, &c_token, &i_token_len, tt_cur);
+ scanner_add_token(p_scanner, &c_token, &i_token_len, tt_cur);
+ if (i < _ADD_SEMICOLON_INDEX)
+ _add_semicolon_to_list(p_scanner);
break;
}
}
@@ -323,6 +312,12 @@ scanner_run(Fype *p_fype) {
scanner_add_token(p_scanner, &c_token, &i_token_len, tt_cur);
}
+ /* Check if there is a ; missing */
+ List *p_list_token = scanner_get_list_token(p_scanner);
+ Token *p_last_token = list_last(p_list_token);
+ if (token_get_tt(p_last_token) != TT_SEMICOLON)
+ _add_semicolon_to_list(p_scanner);
+
scanner_post_task(p_scanner);
char *c_filename = scanner_get_filename(p_scanner);
@@ -344,15 +339,6 @@ scanner_run(Fype *p_fype) {
}
p_fype->c_basename = c_basename;
-
- /*
- c_token = calloc(2, sizeof(char*));
- c_token[0] = ';';
- c_token[1] = '\0';
- i_token_len = 1;
-
- scanner_add_token(p_scanner, &c_token, &i_token_len, TT_STRING);
- */
}
void
diff --git a/src/core/scanner.h b/src/core/scanner.h
index 9a83f9c..e760bc6 100644
--- a/src/core/scanner.h
+++ b/src/core/scanner.h
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
@@ -50,8 +50,7 @@
typedef struct {
int i_current_line_nr;
int i_current_pos_nr;
- int i_num_keywords;
- int i_num_operators;
+ int i_num_tokenends2;
int i_num_tokenends;
char *c_filename;
char *c_codestring;
diff --git a/src/core/scope.c b/src/core/scope.c
index e0b9fcd..f372a6a 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/scope.h b/src/core/scope.h
index ac24edc..6e74e64 100644
--- a/src/core/scope.h
+++ b/src/core/scope.h
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/symbol.c b/src/core/symbol.c
index 71e9012..c6733f5 100644
--- a/src/core/symbol.c
+++ b/src/core/symbol.c
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/symbol.h b/src/core/symbol.h
index 9224d43..755c3f7 100644
--- a/src/core/symbol.h
+++ b/src/core/symbol.h
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/token.c b/src/core/token.c
index 593ae5e..58b334a 100644
--- a/src/core/token.c
+++ b/src/core/token.c
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
diff --git a/src/core/token.h b/src/core/token.h
index 2117fa2..bb57a64 100644
--- a/src/core/token.h
+++ b/src/core/token.h
@@ -5,7 +5,7 @@
*: WWW : http://fype.buetow.org
*: E-Mail : fype@dev.buetow.org
*:
- *: Copyright (c) 2005 2006 2007 2008, Paul Buetow (http://www.pb-labs.com)
+ *: Copyright (c) 2005 2006 2007 2008, Paul C. Buetow (http://www.pb-labs.com)
*: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-