Skip to content

Commit

Permalink
Handle type casting as term. Fix parsing of PTR2INTVAL, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Feb 21, 2011
1 parent 9a27651 commit f884bb0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compilers/opsc/src/Ops/Compiler/Grammar.pm
Expand Up @@ -169,6 +169,9 @@ token term:sym<float_constant_long> { # longer to work-around lack of LTM
token term:sym<reg> { <macro_param> }
token term:sym<macro> { <op_macro> }

# Used for macro-casting. E.g. PTR2INTVAL.
token term:sym<type> { <type_declarator> }

# Assignment
token infix:sym<=> { <sym> <O('%assignment')> }
token infix:sym<|=> { <sym> <O('%assignment')> }
Expand Down
10 changes: 10 additions & 0 deletions t/compilers/opsc/01-parse-body.t
Expand Up @@ -79,6 +79,11 @@ inline op noop(out PMC, in INT) {
opcode_t * next = expr NEXT();
}|, "expr NEXT");

parse_ok($c, q|
inline op noop(out PMC, in INT) {
opcode_t * const next = expr NEXT();
}|, "const expr NEXT");


parse_ok($c, q|
inline op noop(out PMC, in INT) {
Expand Down Expand Up @@ -107,6 +112,11 @@ inline op set(out INT, in NUM) :base_core {
$1 = (INTVAL)($2);
}|, "Casting works 2");

parse_ok($c, q|
inline op set(out INT, in NUM) :base_core {
$1 = PTR2INTVAL(optcode_t *, dest);
}|, "Casting works 3");

# Control statements

parse_ok($c, q|
Expand Down

0 comments on commit f884bb0

Please sign in to comment.