Plugins are dynamic libraries loaded at runtime. They are normally used to provide access to external libraries or applications. Yacas comes with a few plugins, such as the GSL plugin. This chapter contains the documentation generated for each plugin.
To use the plugin, the plugin has to be loaded through:
Use("filescanner"); |
The file scanner plugin offers one principal new function; ScanFiles. The prototype for this function is:
ScanFiles(BaseDirectory,SubDirectory,CallFunction); |
The arguments:
The call-back function should accept three arguments: the base directory, the file name and a boolean specifying if the file is a sub-directory.
The full file name can be obtained by concatenating the file name to the base directory. If the file is a sub-directory, the file name can be used as the name of the sub-directory in subsequent recursive calls to ScanFiles.
For example, the following definition of the function tst can be used as a third argument to ScanFiles, in order to scan directories recursively, printing file names of files in the directories.
// File, print 10 # tst(_a,_b,False) <-- Echo("File: ",b) // Directory, scan recursively 20 # tst(_a,_b,True) <-- ScanFiles(a,b,"tst") |
Then, if the Yacas source is in /Users/ayalpink/yacas/, one can call:
ScanFiles("/Users/someone/yacas/","plugins","tst") |
The first lines of output (in Yacas version 1.0.55) is:
File: plugins/.cvsignore File: plugins/CVS/Entries File: plugins/CVS/Repository File: plugins/CVS/Root File: plugins/doc.txt |
Here the scan went into the CVS sub-directory. Appending these file names to the base directory, /Users/someone/yacas/, would give the full path to the file.
To use the plugin, the plugin has to be loaded through:
Use("pcre"); |
The pcre plugin offers two principal functions: PcreLexer and PcreNextToken. PcreLexer sets up and initializes the tokenizer to scan for a set of regular expressions. A call to PcreNextToken returns the result of the scan in the current file, starting from the current position.
PcreLexer does not interfere with normal reading of a file. When normal read calls are made, the default tokenizer is used. The tokenizer set up by PcreLexer is only used when PcreNextToken is called.
The syntax for PcreLexer is:
PcreLexer(tokens); |
The argument tokens is a list of token definitions. A token definition in turn is a list, with the first element a string containing the regular expression, and the second containing an atom that can describe the type of the token (for easy recognition later).
Calling PcreNextToken() will then return the first matching token from the current input.
The following example sets up the tokenizer to recognize either an integer, or a word consisting only of lowercase letters.
In> DllLoad("pcre") Out> True In> PcreLexer({{"[0-9]+",Integer},{"[a-z]+",Word}}) Out> True In> FromString("123abc")PcreNextToken() Out> {"123",Integer} In> FromString("===abc")PcreNextToken() Out> {"abc",Word} |
This is an example mini-API.
Function AddTwoIntegers(arg1,arg2), calls int add_integers (int arg1, int arg2)
Function AddTwoDoubles(x,y), calls double add_doubles (double x, double y)
Declared struct Bla*
Function CreateBla(arg1,arg2), calls Bla* CreateBla (int arg1, int arg2)
Function BlaSetA(arg1,arg2), calls void BlaSetA (Bla* arg1, int arg2)
Function BlaGetA(arg1), calls int BlaGetA (Bla* arg1)
Constant GL_TRUE refers to the library name GL_TRUE
Constant GL_LINES refers to the library name GL_LINES
Constant GL_POINTS refers to the library name GL_POINTS
Constant GL_LINE_STRIP refers to the library name GL_LINE_STRIP
Constant GL_LINE_LOOP refers to the library name GL_LINE_LOOP
Constant GL_TRIANGLES refers to the library name GL_TRIANGLES
Constant GL_TRIANGLE_STRIP refers to the library name GL_TRIANGLE_STRIP
Constant GL_TRIANGLE_FAN refers to the library name GL_TRIANGLE_FAN
Constant GL_QUADS refers to the library name GL_QUADS
Constant GL_QUAD_STRIP refers to the library name GL_QUAD_STRIP
Constant GL_POLYGON refers to the library name GL_POLYGON
Constant GL_EDGE_FLAG refers to the library name GL_EDGE_FLAG
Constant GL_CURRENT_BIT refers to the library name GL_CURRENT_BIT
Constant GL_POINT_BIT refers to the library name GL_POINT_BIT
Constant GL_LINE_BIT refers to the library name GL_LINE_BIT
Constant GL_POLYGON_BIT refers to the library name GL_POLYGON_BIT
Constant GL_POLYGON_STIPPLE_BIT refers to the library name GL_POLYGON_STIPPLE_BIT
Constant GL_PIXEL_MODE_BIT refers to the library name GL_PIXEL_MODE_BIT
Constant GL_LIGHTING_BIT refers to the library name GL_LIGHTING_BIT
Constant GL_FOG_BIT refers to the library name GL_FOG_BIT
Constant GL_DEPTH_BUFFER_BIT refers to the library name GL_DEPTH_BUFFER_BIT
Constant GL_ACCUM_BUFFER_BIT refers to the library name GL_ACCUM_BUFFER_BIT
Constant GL_STENCIL_BUFFER_BIT refers to the library name GL_STENCIL_BUFFER_BIT
Constant GL_VIEWPORT_BIT refers to the library name GL_VIEWPORT_BIT
Constant GL_TRANSFORM_BIT refers to the library name GL_TRANSFORM_BIT
Constant GL_ENABLE_BIT refers to the library name GL_ENABLE_BIT
Constant GL_COLOR_BUFFER_BIT refers to the library name GL_COLOR_BUFFER_BIT
Constant GL_HINT_BIT refers to the library name GL_HINT_BIT
Constant GL_EVAL_BIT refers to the library name GL_EVAL_BIT
Constant GL_LIST_BIT refers to the library name GL_LIST_BIT
Constant GL_TEXTURE_BIT refers to the library name GL_TEXTURE_BIT
Constant GL_SCISSOR_BIT refers to the library name GL_SCISSOR_BIT
Constant GL_ALL_ATTRIB_BITS refers to the library name GL_ALL_ATTRIB_BITS
Constant GL_MATRIX_MODE refers to the library name GL_MATRIX_MODE
Constant GL_MODELVIEW refers to the library name GL_MODELVIEW
Constant GL_PROJECTION refers to the library name GL_PROJECTION
Constant GL_TEXTURE refers to the library name GL_TEXTURE
Function glBegin(arg1), calls void glBegin (int arg1)
Function glVertex3d(x,y,z), calls void glVertex3d (double x, double y, double z)
Function glEnd(), calls void glEnd ()
Function glClearColor(red,green,blue,alpha), calls void glClearColor (double red, double green, double blue, double alpha)
Function glClear(clear_flags), calls void glClear (int clear_flags)
Function glColor4d(arg1,arg2,arg3,arg4), calls void glColor4d (double arg1, double arg2, double arg3, double arg4)
Function glFrontFace(mode), calls void glFrontFace (int mode)
Function glPointSize(size), calls void glPointSize (double size)
Function glLineWidth(width), calls void glLineWidth (double width)
Function glEnable(cap), calls void glEnable (int cap)
Function glDisable(cap), calls void glDisable (int cap)
Function glPushMatrix(), calls void glPushMatrix ()
Function glPopMatrix(), calls void glPopMatrix ()
Function glLoadIdentity(), calls void glLoadIdentity ()
Function glRotated(angle,x,y,z), calls void glRotated (double angle, double x, double y, double z)
Function glScaled(x,y,z), calls void glScaled (double x, double y, double z)
Function glTranslated(x,y,z), calls void glTranslated (double x, double y, double z)
Function glNormal3d(nx,ny,nz), calls void glNormal3d (double nx, double ny, double nz)
Function glMatrixMode(mode), calls void glMatrixMode (int mode)
Function glOrtho(left,right,bottom,top,near_val,far_val), calls void glOrtho (double left, double right, double bottom, double top, double near_val, double far_val)
Function glFrustum(left,right,bottom,top,near_val,far_val), calls void glFrustum (double left, double right, double bottom, double top, double near_val, double far_val)
Function glViewport(x,y,width,height), calls void glViewport (int x, int y, int width, int height)
Constant GLUT_LEFT_BUTTON refers to the library name GLUT_LEFT_BUTTON
Constant GLUT_MIDDLE_BUTTON refers to the library name GLUT_MIDDLE_BUTTON
Constant GLUT_RIGHT_BUTTON refers to the library name GLUT_RIGHT_BUTTON
Constant GLUT_DOWN refers to the library name GLUT_DOWN
Constant GLUT_UP refers to the library name GLUT_UP
Function GlutMainLoop(window_title,window_width,window_height), calls void GlutMainLoop (input_string window_title, int window_width, int window_height)
Function GlutViewWidth(), calls int GlutViewWidth ()
Function GlutViewHeight(), calls int GlutViewHeight ()
Function GlutEnableAnimation(), calls void GlutEnableAnimation ()
Function GlutDisableAnimation(), calls void GlutDisableAnimation ()
Function glutPostRedisplay(), calls void glutPostRedisplay ()
Function GlutGetElapsedTime(), calls int GlutGetElapsedTime ()