summaryrefslogtreecommitdiff
path: root/docs/pod/fype.html
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-15 23:28:07 +0000
committerPaul Buetow <paul@buetow.org>2008-05-15 23:28:07 +0000
commitbe839900419c7a74c4a46efd279d0ca16b35dc1f (patch)
tree1355c8f238d1c58ffd5cb8803bcc2adf987e79aa /docs/pod/fype.html
parent33c945e58f86267b0d3bdca4c3421155e11eb0d9 (diff)
Moved stuff into trunk.
Diffstat (limited to 'docs/pod/fype.html')
-rw-r--r--docs/pod/fype.html582
1 files changed, 582 insertions, 0 deletions
diff --git a/docs/pod/fype.html b/docs/pod/fype.html
new file mode 100644
index 0000000..b47abe9
--- /dev/null
+++ b/docs/pod/fype.html
@@ -0,0 +1,582 @@
+<?xml version="1.0" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>NAME</title>
+<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<link rev="made" href="mailto:root@chuck.buetow.org" />
+</head>
+
+<body style="background-color: white">
+
+<p><a name="__index__"></a></p>
+<!-- INDEX BEGIN -->
+
+<ul>
+
+ <li><a href="#name">NAME</a></li>
+ <li><a href="#synopses">SYNOPSES</a></li>
+ <li><a href="#about">ABOUT</a></li>
+ <li><a href="#parsing___code_generation">PARSING / CODE GENERATION</a></li>
+ <li><a href="#requirements">REQUIREMENTS</a></li>
+ <li><a href="#getting_started">GETTING STARTED</a></li>
+ <li><a href="#data_types">DATA TYPES</a></li>
+ <ul>
+
+ <li><a href="#the_basic_data_types">The basic data types</a></li>
+ <li><a href="#explicit_type_conversions">Explicit type conversions</a></li>
+ </ul>
+
+ <li><a href="#syntax">SYNTAX</a></li>
+ <ul>
+
+ <li><a href="#comments">Comments</a></li>
+ <li><a href="#statements">Statements</a></li>
+ <li><a href="#paranthesis">Paranthesis</a></li>
+ <li><a href="#scopeing">Scopeing</a></li>
+ <li><a href="#control_statements">Control statements</a></li>
+ </ul>
+
+ <li><a href="#variables">VARIABLES</a></li>
+ <li><a href="#built_in_functions">BUILT IN FUNCTIONS</a></li>
+ <ul>
+
+ <li><a href="#math">Math</a></li>
+ <li><a href="#conditional">Conditional</a></li>
+ <li><a href="#definedness">Definedness</a></li>
+ <li><a href="#bitwise">Bitwise</a></li>
+ <li><a href="#numeric">Numeric</a></li>
+ <li><a href="#system">System</a></li>
+ <li><a href="#i_o">I/O</a></li>
+ </ul>
+
+ <li><a href="#self_defining_procedures_and_functions">SELF DEFINING PROCEDURES AND FUNCTIONS</a></li>
+ <ul>
+
+ <li><a href="#procedures">Procedures</a></li>
+ <li><a href="#nested_procedures">Nested procedures</a></li>
+ <li><a href="#functions">Functions</a></li>
+ <li><a href="#nested_functions">Nested functions</a></li>
+ </ul>
+
+ <li><a href="#author">AUTHOR</a></li>
+ <li><a href="#website">WEBSITE</a></li>
+ <li><a href="#see_also">SEE ALSO</a></li>
+</ul>
+<!-- INDEX END -->
+
+<hr />
+<p>
+</p>
+<h1><a name="name">NAME</a></h1>
+<p><strong>Fype</strong> is <strong>f</strong>or <strong>y</strong>our <strong>p</strong>rogram <strong>e</strong>xecution</p>
+<p><strong>Fype</strong> is <strong>f</strong>ree <strong>y</strong>ack <strong>p</strong>rogramed for <strong>E</strong>LF</p>
+<p>It's not a hype - it's Fype!</p>
+<p>
+</p>
+<hr />
+<h1><a name="synopses">SYNOPSES</a></h1>
+<dl>
+<dt><strong><a name="item_fype__5b_2d_5bhsvtv_5d_5d_file_2efy"><strong>fype</strong> [-[hsvTV]] file.fy</a></strong>
+
+<dt><strong><a name="item_fype__2de__22fype_code_string_3b_22"><strong>fype</strong> -e ``fype code string;''</a></strong>
+
+</dl>
+<p>
+</p>
+<hr />
+<h1><a name="about">ABOUT</a></h1>
+<p>Fype is not yet released! Lots of basic stuff is still missing! See the
+TODO file of the source distribution of Fype!</p>
+<p>Fype is a 32 bit scripting language created for fun. You can use it and comment on it if you like. You could also write patches and mail them to fype at dev dot buetow dot org! Or go visit the IRC channel #coding at irc.german-elite.net and ask rantanplan.</p>
+<p>Fype is developed under the BSD license. See the COPYING file which is included in the source tree.</p>
+<p>Fype should be ``at least as good as AWK''. This does not mean it will be a replacement for AWK but it should support functions, loops and arrays like AWK does but with a different syntax. It should also get extension support like AWK has. I am not talking about GNU AWK but about New AWK, which is included in the *BSD distributions! Fype already has a few features which are not available in AWK. However, AWK has still many features which are not available in Fype as well ;)</p>
+<p>Fancy stuff like OOP or unicode or threading is not yet planed. But fancy stuff like function pointers and closures may be considered for one of the first releases of Fype :)</p>
+<p>
+</p>
+<hr />
+<h1><a name="parsing___code_generation">PARSING / CODE GENERATION</a></h1>
+<p>The Fype syntax is very simple and is using a maximum look ahead of 1 and a very easy top down parsing. Fype is parsing and interpreting its code simultaneous. This means, that syntax errors are only detected during program runtime.</p>
+<p>
+</p>
+<hr />
+<h1><a name="requirements">REQUIREMENTS</a></h1>
+<p>Fype only has been tested on FreeBSD 7.0. Linux may work too. Windows support is not planned. But may work using Cygwin or SFU.</p>
+<p>You will also need:</p>
+<pre>
+ GNU GCC C Compiler (gcc.gnu.org)
+ NetBSD Make aka pmake (GNU Make will not work) (it's included in any *BSD)</pre>
+<p>
+</p>
+<hr />
+<h1><a name="getting_started">GETTING STARTED</a></h1>
+<p>Extract, compile and install Fype:</p>
+<pre>
+ tar xvjf fype.tar.bz2
+ cd fype
+ make
+ sudo make install
+ make clean</pre>
+<p>Run a .fy file:</p>
+<pre>
+ fype test.fy</pre>
+<p>See the ./examples subdir of the Fype source distribution for examples! See also fype -h for a list of all options.</p>
+<p>
+</p>
+<hr />
+<h1><a name="data_types">DATA TYPES</a></h1>
+<p>Fype uses auto type conversion. However, if you want to know what's going on you may take a look at the provided basic datatypes.</p>
+<p>
+</p>
+<h2><a name="the_basic_data_types">The basic data types</a></h2>
+<dl>
+<dt><strong><a name="item_integer"><em>integer</em></a></strong>
+
+<dd>
+<p>Specifies an integer number</p>
+</dd>
+</li>
+<dt><strong><a name="item_double"><em>double</em></a></strong>
+
+<dd>
+<p>Specifies a double number</p>
+</dd>
+</li>
+<dt><strong><a name="item_string"><em>string</em></a></strong>
+
+<dd>
+<p>Specifies a string</p>
+</dd>
+</li>
+<dt><strong><a name="item_number"><em>number</em></a></strong>
+
+<dd>
+<p>May be an integer or a double number</p>
+</dd>
+</li>
+<dt><strong><a name="item_any"><em>any</em></a></strong>
+
+<dd>
+<p>May be of any type above</p>
+</dd>
+</li>
+<dt><strong><a name="item_void"><em>void</em></a></strong>
+
+<dd>
+<p>No type</p>
+</dd>
+</li>
+<dt><strong><a name="item_identifier"><em>identifier</em></a></strong>
+
+<dd>
+<p>It's a variable name or a procedure name or a function name</p>
+</dd>
+</li>
+</dl>
+<p>
+</p>
+<h2><a name="explicit_type_conversions">Explicit type conversions</a></h2>
+<dl>
+<dt><strong><a name="item__28integer_29_integer_any">(<em>integer</em>) <strong>integer</strong> <em>any</em></a></strong>
+
+<dd>
+<p>Converts any type to an integer</p>
+</dd>
+</li>
+<dt><strong><a name="item__28double_29_double_any">(<em>double</em>) <strong>double</strong> <em>any</em></a></strong>
+
+<dd>
+<p>Converts any type to a double</p>
+</dd>
+</li>
+<dt><strong><a name="item__28string_29_string_any">(<em>string</em>) <strong>string</strong> <em>any</em></a></strong>
+
+<dd>
+<p>Converts any type to a string</p>
+</dd>
+</li>
+</dl>
+<p>
+</p>
+<hr />
+<h1><a name="syntax">SYNTAX</a></h1>
+<p>
+</p>
+<h2><a name="comments">Comments</a></h2>
+<p>Text from a <strong>#</strong> character until the end of the current line is considered being a comment. Multi line comments may start with an <strong>#*</strong> and and with an <strong>*#</strong> anywhere. Exceptions are if those signs are inside of strings.</p>
+<p>
+</p>
+<h2><a name="statements">Statements</a></h2>
+<p>A Fype program is a list of statements. Each keyword, expression or function call is part of a statement. Each statement is ended with a semicolon. Example:</p>
+<pre>
+ my bar = 3, foo = 1 + 2;
+ say foo;
+ exit foo - bar;</pre>
+<p>
+</p>
+<h2><a name="paranthesis">Paranthesis</a></h2>
+<p>All paranthesis of function calls are optional. They help to make the code better readable. They also help to force precedences of expressions.</p>
+<p>
+</p>
+<h2><a name="scopeing">Scopeing</a></h2>
+<p>A new scope starts with an { and ends with an }. An exception is a procedure, which does not use its own scope (see later in this manual). Control statements and functions support scopeings. Here is a small example how to use scopes:</p>
+<pre>
+ my foo = 1;</pre>
+<pre>
+ {
+ # Prints out 1
+ put defined foo;
+ {
+ my bar = 2;</pre>
+<pre>
+ # Prints out 1
+ put defined bar;
+ }</pre>
+<pre>
+ # Prints out 0
+ put defined bar;</pre>
+<pre>
+ my baz = 3;
+ }</pre>
+<pre>
+ # Prints out 0
+ say defined bar;</pre>
+<p>
+</p>
+<h2><a name="control_statements">Control statements</a></h2>
+<p>Fype knows the following control statements:</p>
+<dl>
+<dt><strong><a name="item_if__3cexpression_3e__7b__3cstatements_3e__7d">if <em>&lt;expression</em>&gt; { <em>&lt;statements</em>&gt; }</a></strong>
+
+<dd>
+<p>Runs the statements if the expression evaluates to a true value.</p>
+</dd>
+</li>
+<dt><strong><a name="item_ifnot__3cexpression_3e__7b__3cstatements_3e__7d">ifnot <em>&lt;expression</em>&gt; { <em>&lt;statements</em>&gt; }</a></strong>
+
+<dd>
+<p>Runs the statements if the expression evaluates to a false value.</p>
+</dd>
+</li>
+<dt><strong><a name="item_while__3cexpression_3e__7b__3cstatements_3e__7d">while <em>&lt;expression</em>&gt; { <em>&lt;statements</em>&gt; }</a></strong>
+
+<dd>
+<p>Runs the statements as long as the the expression evaluates to a true value.</p>
+</dd>
+</li>
+<dt><strong><a name="item_until__3cexpression_3e__7b__3cstatements_3e__7d">until <em>&lt;expression</em>&gt; { <em>&lt;statements</em>&gt; }</a></strong>
+
+<dd>
+<p>Runs the statements as long as the the expression evaluates to a false value.</p>
+</dd>
+</li>
+</dl>
+<p>
+</p>
+<hr />
+<h1><a name="variables">VARIABLES</a></h1>
+<p>Variables can be defined with the <strong>my</strong> keyword. If you don't assign a value during declaration, then it's using the default integer value 0. Variables may be changed during program runtime. Variables may be deleted using the <strong>undef</strong> keyword! Example of defining variables:</p>
+<pre>
+ my foo = 1 + 2;
+ say foo;</pre>
+<pre>
+ my bar = 12, baz = foo;
+ say 1 + bar;
+ say bar;</pre>
+<pre>
+ my baz;
+ say baz; # Will print out 0</pre>
+<p>You may use the <strong>defined</strong> keyword to check if an identifier has been defined or
+not.</p>
+<pre>
+ ifnot defined foo {
+ say &quot;No foo yet defined&quot;;
+ }</pre>
+<pre>
+ my foo = 1;</pre>
+<pre>
+ if defined foo {
+ put &quot;foo is defined and has the value &quot;;
+ say foo;
+ }</pre>
+<p>
+</p>
+<hr />
+<h1><a name="built_in_functions">BUILT IN FUNCTIONS</a></h1>
+<p>In Fype, operators are built in functions as well. The difference is, that they may be written in infix notation instead in front of the arguments. The types inside the () specify the return types.</p>
+<p>
+</p>
+<h2><a name="math">Math</a></h2>
+<dl>
+<dt><strong><a name="item__28any_29_any__2b_any">(<em>any</em>) <em>any</em> <strong>+</strong> <em>any</em></a></strong>
+
+<dd>
+<p>Special string behavior: A string will get auto convertet into an <em>integer</em>.</p>
+</dd>
+</li>
+<dt><strong><a name="item__28any_29_any__2d_any">(<em>any</em>) <em>any</em> <strong>-</strong> <em>any</em></a></strong>
+
+<dd>
+<p>Special string behavior: A string will get auto convertet into an <em>integer</em>.</p>
+</dd>
+</li>
+<dt><strong><a name="item__28any_29_any__2a_any">(<em>any</em>) <em>any</em> <strong>*</strong> <em>any</em></a></strong>
+
+<dd>
+<p>Special string behavior: A string will get auto convertet into an <em>integer</em>.</p>
+</dd>
+</li>
+<dt><strong><a name="item__28any_29_any__2f_any">(<em>any</em>) <em>any</em> <strong>/</strong> <em>any</em></a></strong>
+
+<dd>
+<p>Special string behavior: A string will get auto convertet into an <em>integer</em>.</p>
+</dd>
+</li>
+</dl>
+<p>
+</p>
+<h2><a name="conditional">Conditional</a></h2>
+<dl>
+<dt><strong><a name="item__28integer_29_any__3d_3d_any">(<em>integer</em>) <em>any</em> <strong>==</strong> <em>any</em></a></strong>
+
+<dt><strong><a name="item__28integer_29_any__21_3d_any">(<em>integer</em>) <em>any</em> <strong>!=</strong> <em>any</em></a></strong>
+
+<dt><strong><a name="item__28integer_29_any__3c_3d_any">(<em>integer</em>) <em>any</em> <strong>&lt;=</strong> <em>any</em></a></strong>
+
+<dt><strong><a name="item__28integer_29_any__3e_3d_any">(<em>integer</em>) <em>any</em> <strong>&gt;=</strong> <em>any</em></a></strong>
+
+<dt><strong><a name="item__28integer_29_any__3c_any">(<em>integer</em>) <em>any</em> <strong>&lt;</strong> <em>any</em></a></strong>
+
+<dt><strong><a name="item__28integer_29_any__3e_any">(<em>integer</em>) <em>any</em> <strong>&gt;</strong> <em>any</em></a></strong>
+
+</dl>
+<p>
+</p>
+<h2><a name="definedness">Definedness</a></h2>
+<dl>
+<dt><strong><a name="item__28integer_29_defined_identifier">(<em>integer</em>) <strong>defined</strong> <em>identifier</em></a></strong>
+
+<dd>
+<p>Returns 1 if <em>identifier</em> has been defined. Returns 0 else.</p>
+</dd>
+</li>
+<dt><strong><a name="item__28integer_29_undef_identifier">(<em>integer</em>) <strong>undef</strong> <em>identifier</em></a></strong>
+
+<dd>
+<p>Tries to undefine/delete the <em>identifier</em>. Returns 1 if success, otherwise 0 is returned.</p>
+</dd>
+</li>
+</dl>
+<p>
+</p>
+<h2><a name="bitwise">Bitwise</a></h2>
+<p>Bitwise operators do not work ATM. The fix is on its way!</p>
+<dl>
+<dt><strong><a name="item__28any_29_any__3c_3c_any">(<em>any</em>) <em>any</em> <strong>&lt;&lt;</strong> <em>any</em></a></strong>
+
+<dt><strong><a name="item__28any_29_any__3e_3e_any">(<em>any</em>) <em>any</em> <strong>&gt;&gt;</strong> <em>any</em></a></strong>
+
+<dt><strong><a name="item__28any_29_any_and_any">(<em>any</em>) <em>any</em> <strong>and</strong> <em>any</em></a></strong>
+
+<dt><strong><a name="item__28any_29_any_or_any">(<em>any</em>) <em>any</em> <strong>or</strong> <em>any</em></a></strong>
+
+<dt><strong><a name="item__28any_29_any_xor_any">(<em>any</em>) <em>any</em> <strong>xor</strong> <em>any</em></a></strong>
+
+<dt><strong><a name="item__28any_29_not_any">(<em>any</em>) <strong>not</strong> <em>any</em></a></strong>
+
+</dl>
+<p>
+</p>
+<h2><a name="numeric">Numeric</a></h2>
+<dl>
+<dt><strong><a name="item__28number_29_neg_number">(<em>number</em>) <strong>neg</strong> <em>number</em></a></strong>
+
+<dd>
+<p>This function returns the negative value of <em>any</em></p>
+</dd>
+</li>
+<dt><strong><a name="item__28integer_29_no__5binteger_5d">(<em>integer</em>) <strong>no</strong> [<em>integer</em>]</a></strong>
+
+<dd>
+<p>This function returns 1 if the argument is 0, otherwise it will return 0! If no
+argument is given, then 0 is returned!</p>
+</dd>
+</li>
+<dt><strong><a name="item__28integer_29_yes__5binteger_5d">(<em>integer</em>) <strong>yes</strong> [<em>integer</em>]</a></strong>
+
+<dd>
+<p>This function always returns 1. The parameter is optional.
+</p>
+</dd>
+<dd>
+<pre>
+
+ # Prints out 1, because foo is not defined
+ if yes { say no defined foo; }</pre>
+</dd>
+</li>
+</dl>
+<p>
+</p>
+<h2><a name="system">System</a></h2>
+<dl>
+<dt><strong><a name="item__28void_29_end">(<em>void</em>) <strong>end</strong></a></strong>
+
+<dd>
+<p>Exits the program with the exit status of 0</p>
+</dd>
+</li>
+<dt><strong><a name="item__28void_29_exit_integer">(<em>void</em>) <strong>exit</strong> <em>integer</em></a></strong>
+
+<dd>
+<p>Exits the program with the specified exit status</p>
+</dd>
+</li>
+<dt><strong><a name="item__28integer_29_fork">(<em>integer</em>) <strong>fork</strong></a></strong>
+
+<dd>
+<p>Fork forks a subprocess. It returns 0 for the child process and the pid of the
+child process otherwise! Example:</p>
+</dd>
+<dd>
+<pre>
+ my pid = fork;</pre>
+</dd>
+<dd>
+<pre>
+ if pid {
+ put &quot;I am the parent process; child has the pid &quot;;
+ say pid;</pre>
+</dd>
+<dd>
+<pre>
+ } ifnot pid {
+ say &quot;I am the child process&quot;;
+ }</pre>
+</dd>
+</li>
+<dt><strong><a name="item__28integer_29_gc">(<em>integer</em>) <strong>gc</strong></a></strong>
+
+<dd>
+<p>Executes the garbage collector and returns the number of items freed! You may
+wonder why most of the time it will return a value of 0! Fype tries to free not
+needed memory asap. This may change in future versions in order to gain faster
+execution of scripts!</p>
+</dd>
+</li>
+</dl>
+<p>
+</p>
+<h2><a name="i_o">I/O</a></h2>
+<dl>
+<dt><strong><a name="item__28any_29_put_any">(<em>any</em>) <strong>put</strong> <em>any</em></a></strong>
+
+<dd>
+<p>Prints out the argument</p>
+</dd>
+</li>
+<dt><strong><a name="item__28any_29_say_any">(<em>any</em>) <strong>say</strong> <em>any</em></a></strong>
+
+<dd>
+<p>Same as put, but also includes an ending newline</p>
+</dd>
+</li>
+<dt><strong><a name="item__28void_29_ln">(<em>void</em>) <strong>ln</strong></a></strong>
+
+<dd>
+<p>Just prints a newline</p>
+</dd>
+</li>
+</dl>
+<p>
+</p>
+<hr />
+<h1><a name="self_defining_procedures_and_functions">SELF DEFINING PROCEDURES AND FUNCTIONS</a></h1>
+<p>
+</p>
+<h2><a name="procedures">Procedures</a></h2>
+<p>A procedure can be defined with the <strong>proc</strong> keyword and deleted with the <strong>undef</strong> keyword. A procedure does not return any value and does not support parameter passing. It's using already defined variables (e.g. global variables). A procedure does not have its own namespace. It's using the calling namespace. It is possible to define new variabes inside of a procedure in the current namespace.</p>
+<pre>
+ proc foo {
+ say 1 + a * 3 + b;
+ my c = 6;
+ }</pre>
+<pre>
+ my a = 2, b = 4;</pre>
+<pre>
+ foo; # Run the procedure. Print out &quot;11\n&quot;
+ say c; # Print out &quot;6\n&quot;;</pre>
+<p>
+</p>
+<h2><a name="nested_procedures">Nested procedures</a></h2>
+<p>It's possible to define procedures inside of procedures. Since procedures don't
+have its own scope, nested procedures will be available to the current scope as
+soon as the main procedure has run the first time. You may use the <strong>defined</strong>
+keyword in order to check if a procedure has been defined or not.</p>
+<pre>
+ proc foo {
+ say &quot;I am foo&quot;;</pre>
+<pre>
+ undef bar;
+ proc bar {
+ say &quot;I am bar&quot;;
+ }
+ }</pre>
+<pre>
+ # Here bar would produce an error because
+ # the proc is not yet defined!
+ # bar;</pre>
+<pre>
+ foo; # Here the procedure foo will define the procedure bar!
+ bar; # Now the procedure bar is defined!
+ foo; # Here the procedure foo will redefine bar again!</pre>
+<p>
+</p>
+<h2><a name="functions">Functions</a></h2>
+<p>A function should be defined with the <strong>func</strong> keyword and deleted with the <strong>undef</strong> keyword. Function not yet return values (will be changed in future versions) and supports not yet parameter passing (will be changed in future versions). It's using local (lexical scoped) variables. If a certain variable does not exist It's using already defined variables (e.g. one scope above).</p>
+<pre>
+ func foo {
+ say 1 + a * 3 + b;
+ my c = 6;
+ }</pre>
+<pre>
+ my a = 2, b = 4;</pre>
+<pre>
+ foo; # Run the procedure. Print out &quot;11\n&quot;
+ say c; # Will produce an error, because c is out of scoped!</pre>
+<p>
+</p>
+<h2><a name="nested_functions">Nested functions</a></h2>
+<p>Nested functions work the same way the nested procedures work, with the exception that nested functions will not be available any more after the function has been left!</p>
+<pre>
+ func foo {
+ func bar {
+ say &quot;Hello i am nested&quot;;
+ }</pre>
+<pre>
+ bar; # Calling nested
+ }</pre>
+<pre>
+ foo;
+ bar; # Will produce an error, because bar is out of scope!</pre>
+<p>
+</p>
+<hr />
+<h1><a name="author">AUTHOR</a></h1>
+<p>Paul C. Buetow (http://paul.buetow.org)</p>
+<p>
+</p>
+<hr />
+<h1><a name="website">WEBSITE</a></h1>
+<p>The Fype Language (http://fype.buetow.org)</p>
+<p>
+</p>
+<hr />
+<h1><a name="see_also">SEE ALSO</a></h1>
+<p><code>awk(1)</code> <code>cc(1)</code> <code>make(1)</code>
+
+</p>
+
+</body>
+
+</html>