summaryrefslogtreecommitdiff
path: root/tests/examplefiles/example.gi
diff options
context:
space:
mode:
authorMax Horn <max@quendi.de>2014-04-05 01:03:33 +0200
committerMax Horn <max@quendi.de>2014-04-05 01:03:33 +0200
commit229905554194fe709e0a53b1c15ac31033b6c123 (patch)
tree758fc4897c72411fa7365db6b4afbec9598e3c0c /tests/examplefiles/example.gi
parent948dffaaeae77b83aa3e506495c6a89e5093d869 (diff)
downloadpygments-229905554194fe709e0a53b1c15ac31033b6c123.tar.gz
Add basic lexer for GAP, a mathematical programming language.
Diffstat (limited to 'tests/examplefiles/example.gi')
-rw-r--r--tests/examplefiles/example.gi64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/examplefiles/example.gi b/tests/examplefiles/example.gi
new file mode 100644
index 00000000..c9c5e55d
--- /dev/null
+++ b/tests/examplefiles/example.gi
@@ -0,0 +1,64 @@
+#############################################################################
+##
+#W example.gd
+##
+## This file contains a sample of a GAP implementation file.
+##
+
+
+#############################################################################
+##
+#M SomeOperation( <val> )
+##
+## performs some operation on <val>
+##
+InstallMethod( SomeProperty,
+ "for left modules",
+ [ IsLeftModule ], 0,
+ function( M )
+ if IsFreeLeftModule( M ) and not IsTrivial( M ) then
+ return true;
+ fi;
+ TryNextMethod();
+ end );
+
+
+
+#############################################################################
+##
+#F SomeGlobalFunction( )
+##
+## A global variadic funfion.
+##
+InstallGlobalFunction( SomeGlobalFunction, function( arg )
+ if Length( arg ) = 3 then
+ return arg[1] + arg[2] * arg[3];
+ elif Length( arg ) = 2 then
+ return arg[1] - arg[2]
+ else
+ Error( "usage: SomeGlobalFunction( <x>, <y>[, <z>] )" );
+ fi;
+ end );
+
+
+#
+# A plain function.
+#
+SomeFunc := function(x, y)
+ local z, func, tmp, j;
+ z := x * 1.0;
+ y := 17^17 - y;
+ func := a -> a mod 5;
+ tmp := List( [1..50], func );
+ while y > 0 do
+ for j in tmp do
+ Print(j, "\n");
+ od;
+ repeat
+ y := y - 1;
+ until 0 < 1;
+ y := y -1;
+ od;
+ return z;
+end;
+ \ No newline at end of file