これよりも1行のコメントを解析する簡単な方法はありますか?
comment
^ '//' asParser ,
(#any asParser starLazy: (#newline asParser)) ,
#newline asParser
==> [ :result | nil "Ignore comments" ]
program
^ (comment / instruction) star
==> [ :result | N2TProgramNode new
setNodes: (result copyWithout: nil) ]
(#newline asParser)と#copyWithout:の繰り返しについては特にわかりません。
Lukasの答えの後、私はもっと簡単な次の解決策を思いつきました。
program
^ programEntity star
==> [ :result | N2TProgramNode new setNodes: result]
programEntity
^ instruction trim: ignorable
ignorable
^ comment / #space asParser
comment
^ '//' asParser , #newline asParser negate star