The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
Difference between revisions of "FLOP:An Ebuild Abstract Syntax Tree"
(Initialize a FLOP) |
m |
||
Line 21: | Line 21: | ||
[https://code.funtoo.org/bitbucket/scm/~d4g33z/bashlextoo.git bashlextoo] is a fork of [https://github.com/idank/bashlex bashlex]. If an ebuild is transformed or normalized via some simple semantic parsing rules, an AST can be created from it via <tt>bashlextoo</tt>. See the repo for an example. | [https://code.funtoo.org/bitbucket/scm/~d4g33z/bashlextoo.git bashlextoo] is a fork of [https://github.com/idank/bashlex bashlex]. If an ebuild is transformed or normalized via some simple semantic parsing rules, an AST can be created from it via <tt>bashlextoo</tt>. See the [https://code.funtoo.org/bitbucket/scm/~d4g33z/feast.git <tt>feast</tt> repo] for an example. |
Latest revision as of 03:29, December 28, 2021
Funtoo Linux Optimization Proposal: An Ebuild Abstract Syntax Tree
feaster: The Funtoo Ebuild Abstract Syntax Tree Tool
Summary
Ebuilds are a rich source of information about software. Their semantics define the ecology of a Funtoo Linux instance: what software can live together under a single root. Their syntax is Bash, a powerful but ill-understood language. I believe that the EAPI may be the most complex single piece of code ever written totally in Bash. Indeed, it achieves a near domain-specific quality with its powerful abstractions. Can certain of those abstractions be lifted out and implemented in another language, e.g. Python?
Architecture
Bash syntax is fairly simple (see https://wiki.bash-hackers.org/syntax/basicgrammar). The nodes of the AST are the following elements:
- a simple command is just a command and its arguments
- a pipeline is one or more simple command probably connected in a pipe
- a list is one or more pipelines connected by special operators
- a compound command is a list or a special command that forms a new meta-command
- a function definition makes a compound command available under a new name, and a separate environment
bashlextoo is a fork of bashlex. If an ebuild is transformed or normalized via some simple semantic parsing rules, an AST can be created from it via bashlextoo. See the feast repo for an example.