-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d27e6e
commit 0e7c4be
Showing
12 changed files
with
2,094 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
%{ | ||
/* | ||
Copyright 2020 Dennis Earl Smiley | ||
|
||
This file is part of biflex. | ||
|
||
biflex is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
biflex is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with pnfasm. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
/* | ||
REM CHANGELOG | ||
REM ========= | ||
|
||
REM 8/5/20 Origional a - 1. The first version. | ||
*/ | ||
/* Prologue */ | ||
#include <desLib/deslib.hpp> | ||
|
||
|
||
void yyerror(char const * c); | ||
String remove_extension(String file); | ||
|
||
|
||
FILE * output; | ||
String output2; | ||
%} | ||
/* Flex Definitions */ | ||
%x comment | ||
|
||
|
||
/* Flex Patterns Below %% */ | ||
%% | ||
|
||
"%%%\n\n\n" { | ||
String outputname = output2 + (char *)".lpp"; | ||
fclose(output); | ||
output = fopen(outputname.getString().c_str(), "w"); | ||
if (!output) | ||
{ | ||
yyerror("can't open file for write"); | ||
return -1; | ||
} | ||
} | ||
|
||
"%" fprintf(output, "%s", yytext); | ||
|
||
[\n\t]+ fprintf(output, "%s", yytext); | ||
|
||
"/**" BEGIN(comment); | ||
|
||
<comment>"**/" BEGIN(INITIAL); | ||
|
||
<comment>. /* Eat up */ | ||
|
||
.|\n fprintf(output, "%s", yytext); | ||
|
||
%% | ||
/* Additional Code */ | ||
int main(int argc, char ** argv) | ||
{ | ||
if (argc == 2) | ||
{ | ||
FILE * input = fopen(argv[1], "r"); | ||
if (!input) | ||
{ | ||
yyerror("can't open file"); | ||
return -1; | ||
} | ||
yyin = input; | ||
|
||
String outputname = remove_extension(argv[1]); | ||
output2 = outputname; | ||
outputname += (char *)".ypp"; | ||
output = fopen(outputname.getString().c_str(), "w"); | ||
if (!output) | ||
{ | ||
yyerror("can't open file for write"); | ||
return -1; | ||
} | ||
|
||
int ret = yylex(); | ||
|
||
|
||
return ret; | ||
} | ||
else | ||
yyerror("can't find input file or output file."); | ||
} | ||
|
||
void yyerror(char const * c) | ||
{ | ||
cout << "* ERROR: " << c << endl; | ||
} | ||
|
||
|
||
String remove_extension(String file) | ||
{ | ||
String ret; | ||
|
||
// Old | ||
// file = strrev((char *)file.getString().c_str()); | ||
file = file.reverse(); | ||
unsigned long pos = file.getString().find('.'); | ||
if (pos == string::npos) | ||
ret = file; | ||
|
||
ret = file.getString().substr(pos + 1); | ||
// Old | ||
//ret = strrev((char *)ret.getString().c_str()); | ||
file = file.reverse(); | ||
|
||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This file is part of biflex. | ||
|
||
# biflex is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
|
||
# biflex is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
|
||
# You should have received a copy of the GNU General Public License | ||
# along with pnfasm. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
# CHANGELOG | ||
# ========= | ||
|
||
# 1/8/23 Origional a - 1. The first version. | ||
|
||
|
||
echo Cleaning... | ||
rm *.cpp | ||
rm biflex | ||
|
||
echo Flex... | ||
flex -l -obiflex.cpp biflex.lpp | ||
|
||
echo C++... | ||
g++ biflex.cpp -o biflex -lfl -Wno-write-strings -fpermissive -static |
File renamed without changes.
File renamed without changes.
File renamed without changes.