showrpn option
This commit is contained in:
parent
35cc0b333b
commit
4d38a2e182
@ -7,7 +7,7 @@ _par()
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="--help --list-arches -h -t -p -b -o -m"
|
||||
opts="-b -h -m -o -p -r --help --list-arches"
|
||||
|
||||
if [[ ${cur} == -* ]]; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
|
2
gen.c
2
gen.c
@ -41,6 +41,8 @@ Vec gen_i2r(const Vec*tokens)
|
||||
for(size_t i=0;i<tokens->size;++i)
|
||||
{
|
||||
|
||||
//printf("[[%s]]\n",vec_at(tokens,i,const Tok*)->str.buffer);
|
||||
|
||||
// identifiers
|
||||
switch(vec_at(tokens,i,const Tok*)->type)
|
||||
{
|
||||
|
1
gen.h
1
gen.h
@ -19,6 +19,7 @@ typedef struct Gen
|
||||
const PNode*rootnode;
|
||||
size_t labelno;
|
||||
uint32_t buildarch;
|
||||
bool showrpn;
|
||||
} Gen;
|
||||
|
||||
// Type of elements in evaluation of RPN Vec
|
||||
|
1
i386.c
1
i386.c
@ -21,6 +21,7 @@ void gen_i386_eval(Gen*gen,const PNode*pn,FILE*file)
|
||||
Vec stack=vec_new(sizeof(eval_elem));
|
||||
|
||||
rpn_stack=gen_i2r(&pn->tokens);
|
||||
if(gen->showrpn)vec_print_tokens(&rpn_stack);
|
||||
|
||||
/* gen_eval_analyze(pn); */
|
||||
|
||||
|
1
lex.c
1
lex.c
@ -179,6 +179,7 @@ void lex_string(Lexer*lex,char*input_string)
|
||||
else if(strcmp("-=",ss)==0)opmatch_nodup(LASSIGN,false);
|
||||
else if(strcmp("*=",ss)==0)opmatch_nodup(LASSIGN,false);
|
||||
else if(strcmp("/=",ss)==0)opmatch_nodup(LASSIGN,false);
|
||||
else opmatch_nodup(LASSIGN,false);
|
||||
}
|
||||
break;
|
||||
default:break;
|
||||
|
8
main.c
8
main.c
@ -7,7 +7,7 @@
|
||||
#include"version.h"
|
||||
|
||||
#define HELPMSG "par v"VERSION"\n"\
|
||||
"usage: par [-htpb] [-o OUTFILE] [-m ARCH] [--help] [--list-arches] [FILES]"
|
||||
"usage: par [-bhprt] [-o OUTFILE] [-m ARCH] [--help] [--list-arches] [FILES]"
|
||||
#define ARCHESMSG "i386\nir\nrun\nx86_64"
|
||||
|
||||
int main(int argc,char**argv)
|
||||
@ -17,6 +17,7 @@ int main(int argc,char**argv)
|
||||
bool showparsetree=false;
|
||||
bool showparsetreebrief=false;
|
||||
bool showtokens=false;
|
||||
bool showrpn=false;
|
||||
char*setoutfile_name=NULL;
|
||||
int skip_arg=0;
|
||||
uint32_t buildarch=M_X86_64;
|
||||
@ -117,6 +118,10 @@ int main(int argc,char**argv)
|
||||
showtokens=true;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
showrpn=true;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
puts(HELPMSG);
|
||||
cleanquit(0);
|
||||
@ -144,6 +149,7 @@ int main(int argc,char**argv)
|
||||
|
||||
state.gen.rootnode=&state.parser.root;
|
||||
state.gen.buildarch=buildarch;
|
||||
state.gen.showrpn=showrpn;
|
||||
|
||||
state.infile=fopen(*vec_at(&args,i,const char**),"r");
|
||||
if(!state.infile)
|
||||
|
30
par.1
30
par.1
@ -6,7 +6,7 @@
|
||||
par \- Lexer, parser, and code generator
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
usage: par [-htpb] [-o OUTFILE] [-m ARCH] [--help] [--list-arches] [FILES]
|
||||
usage: par [-bhprt] [-o OUTFILE] [-m ARCH] [--help] [--list-arches] [FILES]
|
||||
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
@ -15,22 +15,14 @@ Compile source code into binary output
|
||||
.SH "OPTIONS"
|
||||
.IX Header "OPTIONS"
|
||||
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
View possible commands and exit
|
||||
|
||||
.TP
|
||||
\fB\-t\fR
|
||||
View tokens from lexer stage
|
||||
|
||||
.TP
|
||||
\fB\-p\fR
|
||||
View parsing tree (full, including internal tree nodes)
|
||||
|
||||
.TP
|
||||
\fB\-b\fR
|
||||
View parsing tree (brief output)
|
||||
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
View possible commands and exit
|
||||
|
||||
.TP
|
||||
\fB\-m ARCH\fR
|
||||
Change target output (see ARCH, --list-arches)
|
||||
@ -39,6 +31,18 @@ Change target output (see ARCH, --list-arches)
|
||||
\fB\-o OUTFILE\fR
|
||||
Set output filename
|
||||
|
||||
.TP
|
||||
\fB\-p\fR
|
||||
View parsing tree (full, including internal tree nodes)
|
||||
|
||||
.TP
|
||||
\fB\-r\fR
|
||||
View expressions after conversion to Reverse Polish Notation
|
||||
|
||||
.TP
|
||||
\fB\-t\fR
|
||||
View tokens from lexer stage
|
||||
|
||||
.TP
|
||||
\fB\-\-list\-arches\fR
|
||||
List all possible target build architectures.
|
||||
|
Loading…
Reference in New Issue
Block a user