Skip to content

Commit

Permalink
Fix the issue 15
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuichiueda committed Apr 12, 2021
1 parent 70c5ca7 commit 5df1b6d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 34 deletions.
8 changes: 4 additions & 4 deletions src/ArgExtCom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ bool ArgExtCom::parse(void)
// a non small captal letter)

// fullpath command
if( ! m_feeder->smallCapsWithNum(&m_prefix)){
if( ! m_feeder->fileNameSegment(&m_prefix)){
m_feeder->getPos(&m_end_line, &m_end_char);
bool res = m_feeder->command(&m_text);
bool res = m_feeder->path(&m_text);

if(res)
m_evaled_text = m_text;
Expand All @@ -48,7 +48,7 @@ bool ArgExtCom::parse(void)
m_prefix = "";

string tmp;
while(m_feeder->smallCapsWithNum(&tmp)){
while(m_feeder->fileNameSegment(&tmp)){
m_text = m_text + tmp;
if(!m_feeder->str("."))
break;
Expand All @@ -59,7 +59,7 @@ bool ArgExtCom::parse(void)
}

//hereafter, a command name with a prefix
if(!m_feeder->command(&m_text)){
if(!m_feeder->path(&m_text)){
m_error_msg = "Invalid command name";
m_exit_status = 2;
m_feeder->getPos(&m_end_line, &m_end_char);
Expand Down
2 changes: 1 addition & 1 deletion src/DefProc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool DefProc::parse(void)
return false;
}

if(!m_feeder->command(&m_name)){
if(!m_feeder->path(&m_name)){
m_feeder->setPos(m_start_line, m_start_char);
return false;
}
Expand Down
41 changes: 17 additions & 24 deletions src/Feeder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void Feeder::close(void)
m_ifs = NULL;
}

bool Feeder::command(string *ans)
bool Feeder::path(string *ans)
{
if(outOfRange())
return false;
Expand All @@ -66,6 +66,7 @@ bool Feeder::command(string *ans)
return true;
}

/*
bool Feeder::smallCaps(string *ans)
{
if(outOfRange())
Expand All @@ -87,39 +88,29 @@ bool Feeder::smallCaps(string *ans)
checkEol(p);
return true;
}
*/

bool Feeder::smallCapsWithNum(string *ans)
bool Feeder::fileNameSegment(string *ans)
{
if(outOfRange())
return false;

string *p = &m_lines[m_cur_line];

int i = m_cur_char;
//bool first = true;
bool only_num = true;
for(;i < (int)p->length();i++){
/*
if(first){
if( p->at(i) >= 'a' && p->at(i) <= 'z'){
first = false;
continue;
}
break;
}else{
*/
if( p->at(i) >= 'a' && p->at(i) <= 'z'){
only_num = false;
continue;
}if( p->at(i) >= '0' && p->at(i) <= '9'){
continue;
}

break;
//}
if( p->at(i) >= '@' && p->at(i) <= 'Z')
continue;
if( p->at(i) == '_' || p->at(i) == '-')
continue;
if( p->at(i) >= 'a' && p->at(i) <= 'z')
continue;
if( p->at(i) >= '0' && p->at(i) <= '9')
continue;

break;
}

if(i == m_cur_char || only_num)
if(i == m_cur_char)
return false;

*ans = string(p->c_str()+m_cur_char,i-m_cur_char);
Expand Down Expand Up @@ -168,6 +159,7 @@ bool Feeder::blank(void)
return true;
}

/*
bool Feeder::path(string *ans)
{
if(command(ans)){
Expand All @@ -176,6 +168,7 @@ bool Feeder::path(string *ans)
}
return false;
}
*/

bool Feeder::arrayElem(string *name,long *pos)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Feeder.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class Feeder
bool arrayElem(string *name,long *pos);
bool comment(void);
//bool declare(string *ans, string reserved);
bool command(string *ans);
//bool command(string *ans);
bool blank(void);
bool blankLine(void);
bool path(string *ans);
bool smallCaps(string *ans);
bool smallCapsWithNum(string *ans);
//bool smallCaps(string *ans);
bool fileNameSegment(string *ans);
bool positiveInt(long *pos);
bool lineResidual(string *ans);
bool doBlock(string *ans);
Expand Down
2 changes: 1 addition & 1 deletion src/Import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool Import::parsePATH(void)
bool Import::parseAs(void)
{

if(! m_feeder->smallCaps(&m_prefix)){
if(! m_feeder->fileNameSegment(&m_prefix)){
m_feeder->setPos(m_start_line, m_start_char);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int scriptPos(int argc, char const* argv[])

void version(void)
{
cerr << "GlueLang v0.2.3 🌸\n\n"
cerr << "GlueLang v0.2.4 🌸🌸\n\n"
<< "Copyright (C) 2021 Ryuichi Ueda\n"
<< "Released under the MIT License.\n"
<< "https://github.com/ryuichiueda/GlueLang" << endl;
Expand Down

0 comments on commit 5df1b6d

Please sign in to comment.