Skip to content

Instantly share code, notes, and snippets.

@haskellcamargo
Created May 27, 2015 18:58
Show Gist options
  • Save haskellcamargo/36f65b7fe5a794b443f4 to your computer and use it in GitHub Desktop.
Save haskellcamargo/36f65b7fe5a794b443f4 to your computer and use it in GitHub Desktop.
Pre-processor example
%{
#define yes true
#ignore (@) ; ignore shut up operator
#token T_CONSTANT_ENCAPSED_STRING("foo") T_CONSTANT_ENCAPSED_STRING("bar")
#translate <[T_STRING]>\<<T>\> => {
class {
public function mix(<T> $arg) {
test::mix($this, $arg);
}
}
}
}%
-- TODO: Continue
entry-point = "%{", { definition, line-break }, "%}" ;
definition = define
| ignore ;
line-break = "\n"
| "\r"
| "\r\n" ;
define = "#define", valid-value, valid-value ;
valid-value = T_STRING
| "(", ? .* ?, ")" ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment