Discussion:
[Help-bash] Extending lengaje
Azael Reyes
2018-08-21 03:42:04 UTC
Permalink
Hi avery one,

First, Thank in advance to read this email.

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.

My ques is, The name is diferent? or can generate with some command?,
espeficfically i need add a terminal to lexical analizar, how can i do that?

Thank you again
Greg Wooledge
2018-08-21 12:51:31 UTC
Permalink
Post by Azael Reyes
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.
Andy Chu
2018-08-21 15:27:44 UTC
Permalink
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
Post by Azael Reyes
Post by Azael Reyes
I'm experimenting with the code of bash to extend the input
lenguaje(don't
Post by Azael Reyes
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
Post by Azael Reyes
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
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.
Loading...