Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test to ast: test the Stringer-function #28

Open
Tiffilore opened this issue Mar 25, 2021 · 0 comments
Open

add test to ast: test the Stringer-function #28

Tiffilore opened this issue Mar 25, 2021 · 0 comments

Comments

@Tiffilore
Copy link
Owner

Tiffilore commented Mar 25, 2021

The Stringer-fct for asts basically mirrors the input - with some brackets for clarification.

In some cases, however, it is not readable any more.

expl:

>> let remainder = fn(x, y) { if(y > 0){let p = (x/y) * y; x - p}}
let remainder = fn(x, y) if(y > 0) let p = ((x / y) * y);(x - p);

more general:

>> if(cond){a;b} 
ifcond ab
>> if(cond){a}; b 
ifcond ab

it's also not always valid Monkey code:

>> let remainder = fn(x, y) { if(y > 0){let p = (x/y) * y; x - p}}
let remainder = fn(x, y) if(y > 0) let p = ((x / y) * y);(x - p);
>> let remainder = fn(x, y) if(y > 0) let p = ((x / y) * y);(x - p);
            __,__
   .--.  .-"     "-.  .--.
  / .. \/  .-. .-.  \/ .. \
 | |  '|  /   Y   \  |'  | |
 | \   \  \ 0 | 0 /  /   / |
  \ '- ,\.-"""""""-./, -' /
   ''-' /_   ^ ^   _\ '-''
       |  \._   _./  |
       \   \ '~' /   /
        '._ '-=-' _.'
           '-----'
Woops! We ran into some monkey business here!

Test (in pseudocode):

let ast1 = result of parsing input
let mirror = ast1.String()
let ast2 = result of parsing mirror

Then we want: ast1 == ast2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant