Plan 9 from Bell Labs’s /usr/web/sources/contrib/maht/inferno/appl/cmd/yak/yak.b

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


implement Yak;

include "yak.m";

Lexeme.to_string(lex : self ref Lexeme) : string
{
	pick x := lex {
	Function =>
		return sys->sprint("Function %s", x.name);
	Expr =>
		return sys->sprint("Expr = %s", x.value);
	}	
}

parse(b : ref Iobuf)
{
	sys = load Sys Sys->PATH;
	bufio = load Bufio Bufio->PATH;

	c := chan of ref Lexeme;
	spawn lex(b, c);
}

lex(b : ref Iobuf, c : chan of ref Lexeme)
{
	r : int;
	while(r = b.getc() > 0) {
		case r {
		' ' or '\t' or '\n' or '\r' =>
			;
		* => sys->print("%c", r);
		}
	}
}


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.