Plan 9 from Bell Labs’s /usr/web/sources/contrib/maht/inferno/module/mathmap.m

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


Mathmap : module { #mathmap.b

	PATH : con "/dis/lib/mathmap.dis";

	functions : list of string;
	pre_defined_vars : list of string;


	Token :adt {
		text : string;
		pick { 
			Operator =>
			Comparitor =>
			Keyword =>
			Label =>
				typetag : string;
			Function =>
			Predefvar =>
			Number =>
			LeftCBracket =>
			RightCBracket =>
			LeftSBracket =>
			RightSBracket =>
			Comma =>
		}

		send : fn(t : self ref Token, c : chan of ref Token) : ref Token;
		unexpected: fn(t: self ref Token, p : ref Parser) : string;
	};

	Filter : adt {
		name : string;
		options : list of string;
		args : list of ref UserValue;
		code : list of ref Code;
	};

	Code : adt {
		pick {
		Assignment =>
			varname : string;
			argument : ref Argument;
		Evaluation =>
			argument : ref Argument;
		Conditional =>
			condition : ref Argument;
			positive : ref Code;
			negative : ref Code;
		}
	};			

	Argument : adt {
		pick {
		Literal =>
			text : string;
		Function =>
			function : ref Function;
		}
	};

	Function : adt {
		name : string;
		arguments : cyclic array of ref Argument;
	};

	UserValue : adt {
		name : string;
		pick {
			Float =>
				min, max : string;
				default : string;
			Int =>
				min, max : string;
				default : string;
			Bool =>
			Color =>
			Curve =>
			Gradient =>
			Image =>
				options : string;
		}

		arg_init : fn (u : self ref UserValue) : (string, string);
	};

	Parser : adt {
		fname : string;
		line : int;
		tokens : chan of ref Token;
		filters : list of ref Filter;
		variables : list of string;

		tokenizer : fn (p : self ref Parser);
		parse: fn(p : self ref Parser);
		label : fn (p : self ref Parser) : string;
		number : fn(p : self ref Parser) : string;
		number_maybe : fn(p : self ref Parser) : (int, string);
		filter : fn(p : self ref Parser, options : list of string) : ref Filter;
		is_filter : fn(p : self ref Parser, label : string) : string;
		is_variable : fn(p : self ref Parser, label : string) : string;
		conditional : fn(p : self ref Parser);
		code : fn(p : self ref Parser);
		value : fn(p : self ref Parser);
		rhs : fn(p : self ref Parser, bracket : string);
		argument : fn(p : self ref Parser) : ref Argument;
		arguments : fn(p : self ref Parser, firstarg : ref Argument) : array of ref Argument;
		label_typetag : fn(p : self ref Parser) : string;
		operator : fn(p : self ref Parser) : string;
		operator_maybe : fn(p : self ref Parser) : string;
		image_uservalue : fn(p : self ref Parser, options : string) : ref UserValue;
		uservalue : fn(p : self ref Parser, tag : string) : (int, ref UserValue);
		uservalues : fn(p : self ref Parser) : (string, string);
		float_uservalue : fn(p : self ref Parser) : (int, ref UserValue);
		int_uservalue : fn(p : self ref Parser) : (int, ref UserValue);
		bool_uservalue : fn(p : self ref Parser) : ref UserValue;
		color_uservalue : fn(p : self ref Parser) : ref UserValue;
		curve_uservalue : fn(p : self ref Parser) : ref UserValue;
		gradient_uservalue : fn(p : self ref Parser) : ref UserValue;
	};
 
	parse : fn (fname : string);

};

#	Put

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.