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.h
is the public C interface of the Agate language. -
agate.c
is the main file that implements the C interface of the Agate language. -
core.inc
is the basic implementation of the core library, it is generated fromcore.agate
withcore.sh
.
In addition, the following files are provided:
-
debug.inc.c
contains additional functions that are necessary for debugging (for developpers only), this file may be included fromagate.c
. -
agate-run.c
is a driver for standalone bare Agate, it can execute an Agate script from the command line. -
agate.l
,agate.y
are the Flex file and the Bison file for checking Agate syntax -
syntax.c
is the driver for the Flex/Bison parser. -
tests.inc
is the list of all tests, it is generated withtests.sh
. -
tests.c
is the driver for running all the tests. -
agate-support.h
,agate-support.c
are 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
,Float
andChar
as primitive types instead ofNum
. -
Wren
List
is 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
Math
class, not methods ofNum
. -
Agate
Map
can take as key any object that implements ahash
method (and core types do implementhash
). -
Wren module is Agate unit.
-
Calling a method on
this
is done with.method
,method
refers to a variable (local or global). -
Agate has
assert
as a keyword and the behaviour ofassert
can 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.