Skip to content

Commit

Permalink
[tools/find] Describe more of the language in the grammar.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Chu committed Jun 5, 2019
1 parent 02448cc commit f6fa4fb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
23 changes: 23 additions & 0 deletions tools/find/find.pgen2
Expand Up @@ -44,12 +44,31 @@ factor: (
| '-xtype' STRING
| '-perm' STRING

| '-group' STRING
| '-user' STRING
| '-gid' STRING
| '-uid' STRING
| '-nogroup'
| '-nouser' STRING

| '-empty'
| '-executable'
| '-readable'
| '-writable'

# for time (TODO)
| '-amin' STRING
| '-anewer' STRING
| '-atime' STRING

| '-cmin' STRING
| '-cnewer' STRING
| '-ctime' STRING

| '-mmin' STRING
| '-newer' STRING # note -newer not -mnewer
| '-mtime' STRING
| '-newerXY' STRING

# Actions
| '-delete'
Expand All @@ -59,15 +78,19 @@ factor: (
| '-print'
| '-print0'
| '-printf' STRING
| '-ls'

| '-fprint' STRING
| '-fprint0' STRING
| '-fprintf' STRING STRING
| '-fls' STRING

# TODO: can the command be empty?
# parse {}? That is replaced with the current filename.
| '-exec' STRING* terminator
| '-execdir' STRING* terminator
| '-ok' STRING* terminator
| '-okdir' STRING* terminator
)

terminator: ';' | '+'
16 changes: 13 additions & 3 deletions tools/find/parse.py
Expand Up @@ -49,15 +49,25 @@ def Tokens(strs):
'-path', '-ipath',

'-size', '-type', '-xtype', '-perm',

'-group', '-user',
'-gid', '-uid',
'-nogroup', '-nouser',

'-empty', '-executable', '-readable', '-writable',

'-amin', '-anewer', '-atime',
'-cmin', '-cnewer', '-ctime',
'-mmin', '-newer', '-mtime', # note -newer not -mnewer
'-newerXY',

'-delete',
'-prune', '-quit',

'-print', '-print0', '-printf',
'-fprint', '-fprint0', '-fprintf',
'-print', '-print0', '-printf', '-ls',
'-fprint', '-fprint0', '-fprintf', '-fls',

'-exec', '-execdir',
'-exec', '-execdir', '-ok', '-okdir',
]

OPMAP = {}
Expand Down

0 comments on commit f6fa4fb

Please sign in to comment.