/* * term - parse a term and return 1 or 0 depending on whether the term * evaluates to true or false, respectively. * * term ::= * '-'('h'|'d'|'f'|'r'|'s'|'w'|'c'|'b'|'p'|'u'|'g'|'k') filename * '-'('L'|'x') filename * '-t' int * '-'('z'|'n') string * string * string ('!='|'=') string * <int> '-'(eq|ne|le|lt|ge|gt) <int> * file '-'(nt|ot|ef) file * '(' <expr> ')' * int ::= * '-l' string * positive and negative integers */
くだんのサイトざっと見たが (スコア:2, 参考になる)
つーことでFreeBSD-6.2-RELEASEの/usr/src/bin/test/test.c よりコピペ。
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
aexpr ::= nexpr | nexpr "-a" aexpr ;
nexpr ::= primary | "!" primary
primary ::= unary-operator operand
| operand binary-operator operand
| operand
| "(" oexpr ")"
;
unary-operator ::= "-r"|"-w"|"-x"|"-f"|"-d"|"-c"|"-b"|"-p"|
"-u"|"-g"|"-k"|"-s"|"-t"|"-z"|"-n"|"-o"|"-O"|"-G"|"-L"|"-S";
binary-operator ::= "="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
"-nt"|"-ot"|"-ef";
operand ::= <any legal UNIX file name>
*/
GNUのCoreutils-6.9のsrc/test.c にも、こんなの。
/*
* term - parse a term and return 1 or 0 depending on whether the term
* evaluates to true or false, respectively.
*
* term ::=
* '-'('h'|'d'|'f'|'r'|'s'|'w'|'c'|'b'|'p'|'u'|'g'|'k') filename
* '-'('L'|'x') filename
* '-t' int
* '-'('z'|'n') string
* string
* string ('!='|'=') string
* <int> '-'(eq|ne|le|lt|ge|gt) <int>
* file '-'(nt|ot|ef) file
* '(' <expr> ')'
* int ::=
* '-l' string
* positive and negative integers
*/
# OSS万歳。そしてソース探検に感謝。
# http://www.ascii.co.jp/books/books/detail/4-7561-4415-2.shtml
Re:くだんのサイトざっと見たが (スコア:0)