Skip to content
The Fish shell parser written in Go.
Go Yacc
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ast
internal/yyparse
parser
token
.gitignore
README.md

README.md

parsefish

The Fish shell parser written in Go.

Description

This is a library to parse Fish shell script. Use like

tree := parser.ParseExpr("ls -la | cat -\n")

and get AST node tree.

It can be printed like this:

ast.Print(tree)
     0  ast.Stmts (len = 1) {
     1  .  0: ast.PipeStmt {
     2  .  .  Lhs: ast.CmdStmt {
     3  .  .  .  Cmd: ast.StrExpr (len = 1) {
     4  .  .  .  .  0: ast.Ident {
     5  .  .  .  .  .  Name: "ls"
     6  .  .  .  .  }
     7  .  .  .  }
     8  .  .  .  Args: []ast.Expr (len = 1) {
     9  .  .  .  .  0: ast.StrExpr (len = 1) {
    10  .  .  .  .  .  0: ast.Ident {
    11  .  .  .  .  .  .  Name: "-la"
    12  .  .  .  .  .  }
    13  .  .  .  .  }
    14  .  .  .  }
    15  .  .  }
    16  .  .  Rhs: ast.CmdStmt {
    17  .  .  .  Cmd: ast.StrExpr (len = 1) {
    18  .  .  .  .  0: ast.Ident {
    19  .  .  .  .  .  Name: "cat"
    20  .  .  .  .  }
    21  .  .  .  }
    22  .  .  .  Args: []ast.Expr (len = 1) {
    23  .  .  .  .  0: ast.StrExpr (len = 1) {
    24  .  .  .  .  .  0: ast.Ident {
    25  .  .  .  .  .  .  Name: "-"
    26  .  .  .  .  .  }
    27  .  .  .  .  }
    28  .  .  .  }
    29  .  .  }
    30  .  }
    31  }

Project Status

Experimental. The API can be changed roughly!

Author

acomagu

License

MIT

You can’t perform that action at this time.