Skip to content

Instantly share code, notes, and snippets.

Created June 20, 2011 18:26
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 anonymous/1036222 to your computer and use it in GitHub Desktop.
Save anonymous/1036222 to your computer and use it in GitHub Desktop.
# various past examples for context-sensitive node:
# integer constants
$past := PAST::Coerced.new(
$*ST.add_constant('Int', 'int', $<integer>.ast), #default
'IiNn', $<integer>.ast #native
);
# num constants
$past := PAST::Coerced.new(
$*ST.add_constant('Num', 'num', +(~$/)), #default
'IiNn', +(~$/) #native
);
# many contexts
$past := PAST::Coerced.new(
$past, #default
'v', PAST::Op.new(:name('&sink'), $past), #void
'Ii', PAST::... #integer
'Nn', PAST::... #numeric
'Ss', PAST::... #string
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment