[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Extending lengaje
From: |
Andy Chu |
Subject: |
Re: [Help-bash] Extending lengaje |
Date: |
Tue, 21 Aug 2018 08:27:44 -0700 |
Try:
grep yylex parse.y
Yacc generates a parser that calls the yylex() function, and in bash this
is directly in the parse.y file, not in a separate file. It's written by
hand rather than generated by lex.
The bash parser is quite complicated -- if you want something similar in
Python you can look here:
https://github.com/oilshell/oil
$ scripts/count.sh parser
gives an idea of where the code is.
http://www.oilshell.org/release/0.6.pre2/metrics.wwz/line-counts/parser.txt
Andy
On Tue, Aug 21, 2018 at 5:51 AM, Greg Wooledge <address@hidden> wrote:
> On Mon, Aug 20, 2018 at 08:42:04PM -0700, Azael Reyes wrote:
> > I'm experimenting with the code of bash to extend the input
> lenguaje(don't
> > going to obfuscate with detail because is a experiment), I found the
> > 'parse.y' file but I think need the lexical file, I'm expecting found
> some
> > file like 'lex.l' or something similar, but there is not somethink like
> > that.
>
> Bash doesn't use lex/flex during its build process. It only uses bison
> (yacc alternative), in this part of the Makefile:
>
> y.tab.c: parse.y
> # -if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
> $(YACC) -d $(srcdir)/parse.y
> touch parser-built
> # -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; else
> cp -p y.tab.h ${GRAM_H}; fi
>
> y.tab.h: y.tab.c
> @true
>
> Whatever you're looking for, it's in the parse.y file or it doesn't exist
> at all. I suggest paying close attention to every part where the word
> "token" appears.
>
>