WIP metatool
This commit is contained in:
1 parent
1ec2816c07
commit
bcfae7097c
5 files changed
+62
No files matched your search
@@ -20,4 +20,7 @@ acs.err
|
|||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
|
|
||||||
|
# Metaprogram build
|
||||||
|
*.out
|
||||||
|
lex.yy.c
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# There should be nothing in this directory except this file itself on the repo.
|
||||||
|
.
|
||||||
|
!.gitignore
|
||||||
|
|
||||||
|
|
||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
cd meta_src
|
||||||
|
|
||||||
|
flex scanner.l
|
||||||
|
gcc lex.yy.c -o metatool.out
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
%{
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
FILE* outfile1 = NULL;
|
||||||
|
FILE* outfile2 = NULL;
|
||||||
|
FILE* interface_file = NULL;
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%option noyywrap
|
||||||
|
%option nounput
|
||||||
|
%option noinput
|
||||||
|
|
||||||
|
%x LEX_STATE_EXPORT
|
||||||
|
%x LEX_STATE_EXPORT_FUNCTION
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
<INITIAL,LEX_STATE_EXPORT>. fprintf(outfile1, "%s", yytext); fprintf(outfile2, "%s", yytext);
|
||||||
|
<INITIAL>\n fprintf(outfile1, "%s", yytext); fprintf(outfile2, "%s", yytext);
|
||||||
|
<INITIAL>"$export_split" BEGIN(LEX_STATE_EXPORT);
|
||||||
|
|
||||||
|
<LEX_STATE_EXPORT>"function" fprintf(outfile1, "function"); fprintf(outfile2, "function"); fprintf(interface_file, "function"); BEGIN(LEX_STATE_EXPORT_FUNCTION);
|
||||||
|
<LEX_STATE_EXPORT_FUNCTION>"{" fprintf(outfile1, "{"); fprintf(outfile2, "{"); fprintf(interface_file, "{return 0;}"); BEGIN(INITIAL);
|
||||||
|
<LEX_STATE_EXPORT_FUNCTION>(.|\n) fprintf(outfile1, "%s", yytext); fprintf(outfile2, "%s", yytext); fprintf(interface_file, "%s", yytext);
|
||||||
|
<LEX_STATE_EXPORT>\n fprintf(outfile1, "\n"); fprintf(outfile2, "\n"); fprintf(interface_file, "\n"); BEGIN(INITIAL);
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
int main(int argn, char** argv)
|
||||||
|
{
|
||||||
|
if(argn < 4)
|
||||||
|
{
|
||||||
|
printf("Give output file as argument.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
outfile1 = fopen(argv[1], "w");
|
||||||
|
outfile2 = fopen(argv[2], "w");
|
||||||
|
interface_file = fopen(argv[3], "w");
|
||||||
|
|
||||||
|
yylex();
|
||||||
|
|
||||||
|
fclose(outfile1);
|
||||||
|
fclose(outfile2);
|
||||||
|
fclose(interface_file);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user