Skip to content

Instantly share code, notes, and snippets.

@treed
Created February 17, 2011 06:19
Show Gist options
  • Save treed/831135 to your computer and use it in GitHub Desktop.
Save treed/831135 to your computer and use it in GitHub Desktop.
grammar Assembly {
rule TOP { ^ <statement>+ $ }
rule statement {
<operator> <operand> $$
}
rule operator {
| lda
| ldx
| ldy
}
token operand {
'#' <number> # immediate mode
}
token number {
| 25<[0..5]>
| 2<[0..4]><[0..9]>
| 1<[0..9]><[0..9]>
| <[1..9]><[0..9]>
| <[0..9]>
}
}
Assembly.parse("lda #27\nldx #35");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment