Created
August 3, 2014 12:44
-
-
Save takahisa/2f3fc4ff961900c568e9 to your computer and use it in GitHub Desktop.
comment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var any = Chars.Any(); | |
var newline = Combinator.Choice(Chars.Sequence("\u000d\u000a"), | |
Chars.Sequence("\u000d"), | |
Chars.Sequence("\u000a")) | |
.Ignore(); | |
var lineCommentBegin = Chars.Sequence("//"); | |
var lineComment = lineCommentBegin | |
.Right(Flows.Until(any, eof.Or(newline))) | |
.Ignore(); | |
Parser<Char, Unit> blockCommentImpl = null; | |
var blockCommentBegin = Chars.Sequence("/*"); | |
var blockCommentEnd = Chars.Sequence("*/"); | |
var blockComment = Combinator.Lazy(() => blockCommentImpl); | |
var blockCommentRest = blockCommentBegin.Not().Right(blockCommentEnd.Not()).Right(any.Ignore()) | |
.Or(blockComment); | |
var comment = lineComment.Or(blockComment); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment