Skip to content

Commit

Permalink
reverse control char in args
Browse files Browse the repository at this point in the history
  • Loading branch information
tmaradc committed Jun 6, 2023
1 parent e792933 commit f55781d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
14 changes: 0 additions & 14 deletions brili.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,6 @@ type Pointer = {
type Value = boolean | BigInt | Pointer | number | string;
type Env = Map<bril.Ident, Value>;

const controlChars = new Map<string, number>([
["\\0", 0],
["\\a", 7],
["\\b", 8],
["\\t", 9],
["\\n", 10],
["\\v", 11],
["\\f", 12],
["\\r", 13]
]);

/**
* Check whether a run-time value matches the given static type.
*/
Expand Down Expand Up @@ -865,9 +854,6 @@ function evalFunc(func: bril.Function, state: State): Value | null {

function parseChar(s: string): string {
let c = s;
if (controlChars.has(c)) {
c = String.fromCharCode(controlChars.get(c) as number)
}
if (c.length == 1) {
return c;
} else {
Expand Down
6 changes: 3 additions & 3 deletions test/interp/char/char_args.bril
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ARGS: h e y '\n'
@main(c1 : char, c2 : char, c3 : char, c4 : char) {
print c1 c2 c3 c4;
# ARGS: h e y
@main(char_one : char, char_two : char, char_three : char) {
print char_one char_two char_three;
}
3 changes: 1 addition & 2 deletions test/interp/char/char_args.out
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
h e y

h e y

0 comments on commit f55781d

Please sign in to comment.