hello, using perl6 version 2014.04 built on MoarVM version 2014.04
i'm trying to write a grammar to parse the result of a `getent passwd` but when i test the gecos (which could be empty), i fall into a loop. the pb appears whenever i try to match something that can be empty using the * quantifier. I guess i miss a simple point there but i can't figure out what. Any help (or feedback on any other part of the code) would be appreciated. regards use v6; use Test; grammar PAccountDB { token TOP { ^ <account>* $ } token account { <login> ':' <passwd> ':' <uid> ':' <gid> ':' <gecos> ':' <home> ':' <shell> \n } token login { <[a..z]>+ } token passwd { 'x' } token numid { \d+ } token uid { <.numid> } token gid { <.numid> } token gecos { [^:]* } token path { '/' <-[\x00'/']>+ } token home { <.path> } token shell { <.path> } } for ( uid => '445' , gid => '445' , shell => '/bin/false' , home => '/home/mc' # , gecos => 'server account,,,' , login => 'root' ) { my ( $rule, $candidate ) = .kv; ok ?PAccountDB.subparse( $candidate, :rule($rule) ) , "subrule $rule matches $candidate"; } -- Marc Chantreux Université de Strasbourg, Direction Informatique 14 Rue René Descartes, 67084 STRASBOURG CEDEX ☎: 03.68.85.57.40 http://unistra.fr "Don't believe everything you read on the Internet" -- Abraham Lincoln