Skip to content

Alpaca is a programming language that enforces the Entity-Component-System (ECS) paradigm.

Notifications You must be signed in to change notification settings

areverii/Alpaca

Repository files navigation

Alpaca ˙ᵕ˙

✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖
                          Group Members
                        *ੈ✩‧₊˚༺☆༻*ੈ✩‧₊˚

      ˚₊·—̳͟͞͞♡   Nicholas Woodward - nick.woodward@tufts.edu
      ˚₊·—̳͟͞͞♡   Phila Dlamini - phila.dlamini@tufts.edu
      ˚₊·—̳͟͞͞♡   Elliot Bonner - elliot.bonner@tufts.edu
      ˚₊·—̳͟͞͞♡   Nathan Solomon - nathan.solomon@tufts.edu
✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖✧˖°.˖

RUNNING DEMOS
from alpaca folder, call
   make ../demos/[demo_name].exe
   ../demos/[demo_name].exe
   
BUILD THE ALPACA COMPILER
   make all

RUN TEST SUITE:
   make testall

RUNNING A SINGLE SPECIFIED POSITIVE TEST:
   make test_[TESTNAME].exe

RUN SEMANTICALLY NEGATIVE TEST SUITE:
   ./testAlpacaNegative.py

RUN PARSER TESTS:
   ./testAlpacaParser.py

RUN SEMANTIC CHECKER TESTS:
   ./testAlpacaSemant.py
After extracting the zip, the .py files may not be executable, resulting in a "Permission Denied" error on many of the above
commands. Run "chmod +x *.py" to fix this.

GENERATE EXECUTABLES FROM SOURCE FILE NAMES (.alp files):
   make [FILENAME].exe [FILENAME2.exe] ...

TEST PROGRAM DESCRIPTIONS:
-- Test files are located in the tests directory. Each test consists of a .alp
   code file and .out reference output file.

-- List of Unit Tests for scanner and parser:
   addition.in - Alpaca program with components and addition operations
   complicated.in - multiple components, systems, and entities
   expressionNoFunction.in.bad - a file with a single variable and no main
   extralines.in - program with a lot of whitespace. should not affect program
   fail_entity.in.bad - empty entity declaration 
   forLoop.in - write a for loop test
   hello.in - print hello world
   ifStatements.in - a bunch of nested if statements 
   incorrectSyntax.in.bad - old system syntax and uses curly braces 
   interlaving.out.bad - mixes functions and system
   missingEnds.in.bad - function and for loop block missing end keyword
   multipleQueries.in - system with two queries in it
-- List of Unit Tests for semantic checker:
   comp_assign_bad_type.in.bad - assigns an int to a string component
   comp_assign_exists_non.in.bad - assigns to non existent entity
   comp_assign.in - valid component assignment 
   comp_mem_no_comp.in - assigns a member of a non-existent component
   comp_mem_no_ent - entity does not exist. Was never defined
   comp_mem_no_field - assigns to non existent field of component
   comp_mem - valid query and assignment to an entity
   component.in - simple component declaration
   dup_comp_fields - duplicate members in a component
   dup_comps_queried - duplicate components in a query
   dup_comps - duplicate component declaration
   dup_ents - duplicate entity declaration
   entities.in - simple entity and component declaration
   no_ent - attempts to define an entity type using a component that does not exist
   query_undefined_components - attempts to query a component that does not exist.
   spawn_dup_assigns - attempts to assign to the same comp member twice
   spawn_no_ent_comp - attempts to spawn an entity with a component not part of that entity type
   spawn_no_ent - attempts to spawn an entity name that does not exist
   spawn_no_member - adds an extra member when performing a spawn
   spawn - checks that semantic checking passes on a spawn using several different types
   system - an example of a valid system
-- List of Integration Tests and descriptions: 
   append.alp - Tests the append standard library function
   back.alp - Tests the back standard library function
   escapechars.alp - Tests escape characters
   factorial.alp - Tests recursive functions
   for.alp - Tests a simple for loop
   funcargs.alp - Tests that function arguments are properly received and used
   helloworld.alp - In a main function, prints the string "Hello World"
   if.alp - Tests simple if and if else statements
   len.alp - Tests the len standard library function
   listbasics.alp - Tests list exspressions and indexing
   modsigns.alp - Tests the modulus operator
   operators.alp - Tests all operators. These operators include +, -, *, /, %, <, >, <=, >=, ==, !=, and, or, not >>, <<, ^, &, |
   pop_back.alp - Tests the pop_back standard library function
   simplefuncs.alp - Calls a function that prints the int 5000000000 (greater than what fits in a 32 bit int), then main prints "String!" and the float 3.453
   slice.alp - Tests the slice standard library function
   system.alp - Tests basic use of entities, components, and systems
   variables.alp - Tests assigning to variables (int, string, and bool) and checks their initial values
   while-system.alp - Tests a while in a system working with enitities
   while.alp - Tests a simple while loop
-- Invalid tests:
   badcall.alp - Calls a function with an incorrect argument type
   badvartype_int.alp - Attempts to apply a boolean operator to an int variable
   main_args_missing.alp - Program with the required "args" argument to the main function missing
   spawn_bad_assign.alp - Attempts to assign an incorrect type to the member of a component on an entity being spawned
   system.alp - Declares the same query list name for two queries in a system

TEST SCRIPT VALIDATION:
Valid code:
Our test script compiles .alp into .exe, then runs the .exe and compares the output to 
the matching .out file, which contains the gold standard. If the outputs match, then the code
has compiled correctly.

Invalid code:
If the source code is invalid, an error is raised in the compilation process 
(i.e. scanning, parsing, semantically checking the ast, etc). The corresponding 
.exe file is not built. The script attempts to compile the .alp file and compare the error
to the .out file to ensure the correct error was generated.

RUN PARSER
dune exec alpaca -- -a

RUN SEMANT
dune exec alpaca -- -s

RUN CODEGEN
dune exec alpaca -- -c



   ⠀⠀⠀⠀⠀⠀⠀⣾⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣶⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⠀⠀⡇⢻⡽⣶⣄⣀⣀⣤⣤⣤⣄⣼⠏⢹⢷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⢠⣼⡟⠛⠛⠶⠟⠉⠙⠉⠁⠉⢻⡿⠀⢸⡎⣷⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⢀⣶⠿⠛⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⢿⣷⣼⣧⠹⣯⢻⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⢀⣾⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠉⠙⢿⠀⢹⡄⠻⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⢠⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠈⠿⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠺⣿⡶⣶⣄⣀⣀⣾⣤⣴⣾⣿⣶⡶⠿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⢺⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⢀⣴⠟⠀⠀⠉⠛⠋⠀⠀⠀⢰⣿⣿⣷⠀⢸⣷⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⢠⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⠿⠃⠀⢰⣿⠀⠀⠀⠀⠀⠀⠀⠀⢿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⣿⠀⢰⡴⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡿⠛⠋⠀⠀⠀⠀⠀⠀⠀⠀⣼⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠻⣇⠀⡇⠀⠀⠀⠀⣀⣀⠀⠀⠀⢀⣴⠿⠓⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠙⠻⠿⣦⣤⣤⣤⠿⠋⠀⠀⠀⢘⣿⠴⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⠘⣿⡛⠛⠒⠶⠶⠶⠾⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⠀⢨⣟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠚⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⠀⢈⡿⠒⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⠀⠸⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⠀⢰⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⠀⣾⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⠈⣿⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⠰⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣽⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⣼⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠿⠻⠿⠛⠛⠿⣶⢶⣤⣤⣀⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⢿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠉⠉⠛⣷⣤⣀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠘⠛⣿⡆⠀⠀⠀
   ⠀⠀⠀⠀⢠⡿⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣄⠀⠀
   ⠀⠀⠀⠀⣸⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢹⣧⠀
   ⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡤
   ⠀⠀⠀⢸⡏⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡏
   ⠀⠀⠀⠹⣷⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣷
   ⠀⠀⠀⠀⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿
   ⠀⠀⠀⠀⠈⣿⠓⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡯
   ⠀⠀⠀⠀⠀⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇
   ⠀⠀⠀⠀⠀⠈⠹⣷⡂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⢁
   ⠀⠀⠀⠀⠀⠀⠀⠾⣿⣄⠀⠀⠀⠀⠀⣰⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡄⠀⠀⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⡏⠀
   ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣶⣄⠀⠀⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢈⡿⠀⠀⠀⠀⠀⣸⡃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡿⠀⠀
   ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻⡎⠛⠿⠷⢼⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣧⡶⣶⣦⣴⢶⣼⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⡿⠁⠀⠀
   ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻⣦⣀⠀⠀⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⢸⡿⠀⠀⠀⠘⣿⣄⠀⠻⣷⡀⠀⠀⠀⠀⠀⠀⣸⡟⠁⠀⠀⠀
   ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⣿⠀⠀⢈⡿⣷⣄⠀⠀⠀⠀⠀⣠⡿⠃⠀⠀⠀⠀⠈⢻⣇⠀⣸⡿⣷⠀⠀⠀⣶⠾⠋⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣶⣢⡿⠃⠈⢻⡇⠀⠀⣠⡾⠟⠀⠀⠀⠀⠀⠀⠀⠿⠿⠾⠋⠀⣿⣀⢀⣾⡏⠀⠀⠀⠀⠀⠀⠀
   ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠩⠉⡀⠀⢀⣾⣧⢀⣼⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠀⠀⢘⡿⠷⠿⣋⠀⠀⠀⠀

About

Alpaca is a programming language that enforces the Entity-Component-System (ECS) paradigm.

Resources

Stars

Watchers

Forks

Packages

No packages published