Skip to content

Instantly share code, notes, and snippets.

@titsuki
Last active December 3, 2017 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save titsuki/ed10656d585a8c8cdf50787291c241ed to your computer and use it in GitHub Desktop.
Save titsuki/ed10656d585a8c8cdf50787291c241ed to your computer and use it in GitHub Desktop.
grammar Infobox::Grammar {
token TOP { <infobox> .+ }
token infobox { '{{Infobox' <.ws> <name> \n <propertylist> '}}' }
token name { <-[\n]>+ }
token propertylist {
[
| <property> \n
| \n
]+
}
token property {
[
| '|' <key=.key-content> '=' <value=.value-content-list>
| '|' <key=.key-content> '=' # (#4)
]
}
token key-content { <-[=\n]>+ }
token value-content-list {
[
| <value-content> <br> # (#6)
| <value-content>
| <br>
]+
}
token value-content-list-nl { # (#1)
[
| <value-content> <br> # (#7)
| <value-content>
| <br>
]+ % \n
}
token value-content {
[
| <anchortext>
| <weblink>
| <rawtext>
| <template>
| <delimiter>
| <sup>
]+
}
token br { # (#5)
[
| '<br />'
| '<br/>'
| '<br>'
]
}
token template {
[
| '{{' <-[\n]>+? '}}'
| '{{nowrap' '|' <value-content-list> '}}' # (#3)
| '{{Plainlist' '|' \n <value-content-list-nl> \n '}}' # (#2)
]
}
token anchortext { '[[' <-[\n]>+? ']]' }
token weblink { '[' <-[\n]>+? ']' }
token rawtext { <-[\|\[\]\n、\,\<\>\}\{]>+ }
token delimiter { [ '、' | ',' | '&nbsp;' ] }
token sup { '<sup>' <-[\n]>+? '</sup>'}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment