Created
January 15, 2014 08:06
-
-
Save joeriks/8432496 to your computer and use it in GitHub Desktop.
peg grammar for simple name parsing
This file contains 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
start = (fullname:fullname "\n"? {return fullname})* | |
name = | |
char:[A-Za-z]+ { return char.join(""); } | |
fullname = | |
firstName:name " " secondName:name {return {fn:firstName, sn:secondName}} | |
/* foo bar | |
baz bang */ | |
=> | |
/* | |
[{fn:"foo", sn:"bar"},{fn:"baz",sn:"bang"}] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment