Skip to content

Instantly share code, notes, and snippets.

@samcv
Created May 9, 2017 21:02
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 samcv/9c08cbff64bb8b21d18cbbf9e37536f7 to your computer and use it in GitHub Desktop.
Save samcv/9c08cbff64bb8b21d18cbbf9e37536f7 to your computer and use it in GitHub Desktop.
#÷ [0.2] SPACE (Other) ÷ [999.0] SPACE (Other) ÷ [0.3]
# Default Grapheme Break Test
#
# Format:
# <string> (# <comment>)?
# <string> contains hex Unicode code points, with
# ÷ wherever there is a break opportunity, and
# × wherever there is not.
# <comment> the format can change, but currently it shows:
# - the sample character name
# - (x) the Grapheme_Cluster_Break property value for the sample character
# - [x] the rule that determines whether there is a break or not
grammar GraphemeBreakTest {
token TOP { [<.ws> [<break-nobreak>] <.ws>]+ % <hex> <comment> }
token break-nobreak {
<nobreak> | <break>
}
token hex {
<:AHex>+
}
token nobreak {
'÷'
}
token break {
'×'
}
token comment {
'#' .* $
}
}
class parser {
method TOP ($/) {
say $/.list
}
#method hex ($/) {
# say :16(~$/);
#}
}
GraphemeBreakTest.new.parse(
'÷ 0021 ÷ 0020 ÷ # ÷ [0.2] SPACE (Other) ÷ [999.0] SPACE (Other) ÷ [0.3]'
, actions => parser.new
).made;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment