parsefile
ErrorsCollection

parsefile

Synthesised documentation from type/Grammar

From type/Grammar

See Original text in context

method parsefile(Str(Cool$filename:$enc*%opts)

Reads file $filename encoding by $enc, and parses it. All named arguments are passed on to method parse.

grammar Identifiers {
    token TOP        { [<identifier><.ws>]+ }
    token identifier { <initial> <rest>* }
    token initial    { <+myletter +[_]> }
    token rest       { <+myletter +mynumber +[_]> }
    token myletter   { <[A..Za..z]> }
    token mynumber   { <[0..9]> }
}
 
say Identifiers.parsefile('users.txt':enc('UTF-8'))
    .Str.trim.subst(/\n/',':g);
 
# users.txt : 
# TimToady 
# lizmat 
# jnthn 
# moritz 
# zoffixznet 
# MasterDuke17 
 
# OUTPUT: «TimToady,lizmat,jnthn,moritz,zoffixznet,MasterDuke17␤»