Skip to main content

module demo::lang::Lisra::Pretty

rascal-0.40.17

Usage

import demo::lang::Lisra::Pretty;

Dependencies

import demo::lang::Lisra::Runtime;

function pretty

str pretty(Integer(n))  = "<n>";

str pretty(Atom(name)) = name;

str pretty(List(list[Lval] elms)) = "( <for(Lval e <- elms){><pretty(e)> <}>)";

str pretty(Closure(fn)) = "Closure(<fn>)";

Tests

test pretty1

test bool pretty1() = pretty(Integer(123)) == "123";

test pretty2

test bool pretty2() = pretty(Atom("abc")) == "abc";

test pretty3

test bool pretty3() = pretty(List([])) == "( )";

test pretty4

test bool pretty4() = pretty(List([Integer(123)])) == "( 123 )";

test pretty5

test bool pretty5() = pretty(List([Integer(123), Atom("abc")])) == "( 123 abc )";