Some parts of the code are documented here.
Overview
Introduction to Agate code source
Agate is a kind of fork of Wren, the basic implementation comes from Wren with functions and types that have been renamed and/or refactored. If you want to understand some parts of Agate source code, you should look in Wren source code and its excellent comments.
Agate is implemented with three files:
-
agate.his the public C interface of the Agate language. -
agate.cis the main file that implements the C interface of the Agate language. -
core.incis the basic implementation of the core library, it is generated fromcore.agatewithcore.sh.
In addition, the following files are provided:
-
debug.inc.ccontains additional functions that are necessary for debugging (for developpers only), this file may be included fromagate.c. -
agate-run.cis a driver for standalone bare Agate, it can execute an Agate script from the command line. -
agate.l,agate.yare the Flex file and the Bison file for checking Agate syntax -
syntax.cis the driver for the Flex/Bison parser. -
tests.incis the list of all tests, it is generated withtests.sh. -
tests.cis the driver for running all the tests. -
agate-support.h,agate-support.care files that implement some functions needed in the Agate configuration, they can be used as is.
Differences with Wren
Agate is largely based on Wren. Here are the main differences:
-
Variables are declared with
def, notvar. -
Agate has
Int,FloatandCharas primitive types instead ofNum. -
Wren
Listis AgateArray. -
Functions can be declared with
def(but also withFn.new()). -
Functions can be called directly with
f()without.call. Classes can implement a()method to be callable. -
Math functions are in the
Mathclass, not methods ofNum. -
Agate
Mapcan take as key any object that implements ahashmethod (and core types do implementhash). -
Wren module is Agate unit.
-
Calling a method on
thisis done with.method,methodrefers to a variable (local or global). -
Agate has
assertas a keyword and the behaviour ofassertcan be defined at runtime. -
Agate has no concurrency (and do not plan to introduce concurrency), so no
Fiber. -
Agate has no annotations (and do not plan to introduce annotations).
-
Agate is reentrant!
-
Coding conventions are different: Agate methods, functions and variables are in snake case rather than camel case.