mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-06-15 12:29:32 +00:00
added support for hashbang lines (if file starts with '#', line is ignored)
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@270 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
21cc635bc8
commit
94f36db2e5
|
@ -246,7 +246,6 @@ void flow_do_while(struct do_while *loop)
|
||||||
// parse a whole source code file
|
// parse a whole source code file
|
||||||
void flow_parse_and_close_file(FILE *fd, const char *filename)
|
void flow_parse_and_close_file(FILE *fd, const char *filename)
|
||||||
{
|
{
|
||||||
//TODO - check for bogus/malformed BOM and ignore!
|
|
||||||
// be verbose
|
// be verbose
|
||||||
if (config.process_verbosity > 2)
|
if (config.process_verbosity > 2)
|
||||||
printf("Parsing source file '%s'\n", filename);
|
printf("Parsing source file '%s'\n", filename);
|
||||||
|
|
15
src/input.c
15
src/input.c
|
@ -48,7 +48,7 @@ void Input_new_file(const char *filename, FILE *fd)
|
||||||
Input_now->original_filename = filename;
|
Input_now->original_filename = filename;
|
||||||
Input_now->line_number = 1;
|
Input_now->line_number = 1;
|
||||||
Input_now->source = INPUTSRC_FILE;
|
Input_now->source = INPUTSRC_FILE;
|
||||||
Input_now->state = INPUTSTATE_NORMAL;
|
Input_now->state = INPUTSTATE_SOF;
|
||||||
Input_now->src.fd = fd;
|
Input_now->src.fd = fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +117,19 @@ static char get_processed_from_file(void)
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (Input_now->state) {
|
switch (Input_now->state) {
|
||||||
|
case INPUTSTATE_SOF:
|
||||||
|
// fetch first byte from the current source file
|
||||||
|
from_file = getc(Input_now->src.fd);
|
||||||
|
IF_WANTED_REPORT_SRCCHAR(from_file);
|
||||||
|
//TODO - check for bogus/malformed BOM and ignore?
|
||||||
|
// check for hashbang line and ignore
|
||||||
|
if (from_file == '#') {
|
||||||
|
// remember to skip remainder of line
|
||||||
|
Input_now->state = INPUTSTATE_COMMENT;
|
||||||
|
return CHAR_EOS; // end of statement
|
||||||
|
}
|
||||||
|
Input_now->state = INPUTSTATE_AGAIN;
|
||||||
|
break;
|
||||||
case INPUTSTATE_NORMAL:
|
case INPUTSTATE_NORMAL:
|
||||||
// fetch a fresh byte from the current source file
|
// fetch a fresh byte from the current source file
|
||||||
from_file = getc(Input_now->src.fd);
|
from_file = getc(Input_now->src.fd);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
// values for input component "src.state"
|
// values for input component "src.state"
|
||||||
enum inputstate {
|
enum inputstate {
|
||||||
|
INPUTSTATE_SOF, // start of file (check for hashbang)
|
||||||
INPUTSTATE_NORMAL, // everything's fine
|
INPUTSTATE_NORMAL, // everything's fine
|
||||||
INPUTSTATE_AGAIN, // re-process last byte
|
INPUTSTATE_AGAIN, // re-process last byte
|
||||||
INPUTSTATE_SKIPBLANKS, // shrink multiple spaces
|
INPUTSTATE_SKIPBLANKS, // shrink multiple spaces
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#define RELEASE "0.97" // update before release FIXME
|
#define RELEASE "0.97" // update before release FIXME
|
||||||
#define CODENAME "Zem" // update before release
|
#define CODENAME "Zem" // update before release
|
||||||
#define CHANGE_DATE "28 June" // update before release FIXME
|
#define CHANGE_DATE "29 June" // update before release FIXME
|
||||||
#define CHANGE_YEAR "2020" // update before release
|
#define CHANGE_YEAR "2020" // update before release
|
||||||
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
|
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
|
||||||
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME
|
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME
|
||||||
|
|
Loading…
Reference in New Issue
Block a user