Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions aura.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
from aura_lang.lexer import Lexer
from aura_lang.parser import Parser
from aura_lang.interpreter import evaluate, Environment, BUILTINS, Function as AuraFunction
from aura_lang import ast
from languages.aura.lexer import Lexer
from languages.aura.parser import Parser
from languages.aura.interpreter import evaluate, Environment, BUILTINS, Function as AuraFunction
from languages.aura import ast

def main():
if len(sys.argv) < 2:
Expand Down
21 changes: 0 additions & 21 deletions integration_demo.aura

This file was deleted.

7 changes: 0 additions & 7 deletions integration_demo.lfi_ill

This file was deleted.

24 changes: 12 additions & 12 deletions knowledge_core/symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"_type": "tag",
"name": "TestTypeChecker",
"path": "./test_type_checker.py",
"path": "./languages/appl/test_type_checker.py",
"language": "Python",
"line": 29,
"kind": "class",
Expand Down Expand Up @@ -174,7 +174,7 @@
{
"_type": "tag",
"name": "InterpError",
"path": "./interpreter.py",
"path": "./languages/appl/interpreter.py",
"language": "Python",
"line": 32,
"kind": "class",
Expand Down Expand Up @@ -291,7 +291,7 @@
{
"_type": "tag",
"name": "TInt",
"path": "./appl_ast.py",
"path": "./languages/appl/ast.py",
"language": "Python",
"line": 3,
"kind": "class",
Expand Down Expand Up @@ -1335,7 +1335,7 @@
{
"_type": "tag",
"name": "TestParser",
"path": "./test_parser.py",
"path": "./languages/appl/test_parser.py",
"language": "Python",
"line": 25,
"kind": "class",
Expand Down Expand Up @@ -1479,7 +1479,7 @@
{
"_type": "tag",
"name": "Action",
"path": "./planning.py",
"path": "./languages/appl/planning.py",
"language": "Python",
"line": 1,
"kind": "class",
Expand Down Expand Up @@ -1614,7 +1614,7 @@
{
"_type": "tag",
"name": "Parser",
"path": "./parser.py",
"path": "./languages/appl/parser.py",
"language": "Python",
"line": 4,
"kind": "class",
Expand Down Expand Up @@ -1704,7 +1704,7 @@
{
"_type": "tag",
"name": "TestInterpreter",
"path": "./test_interpreter.py",
"path": "./languages/appl/test_interpreter.py",
"language": "Python",
"line": 26,
"kind": "class",
Expand Down Expand Up @@ -1848,7 +1848,7 @@
{
"_type": "tag",
"name": "TypeCheckError",
"path": "./type_checker.py",
"path": "./languages/appl/type_checker.py",
"language": "Python",
"line": 8,
"kind": "class",
Expand Down Expand Up @@ -7275,7 +7275,7 @@
{
"_type": "tag",
"name": "Object",
"path": "./aura_lang/interpreter.py",
"path": "./languages/aura/interpreter.py",
"language": "Python",
"line": 7,
"kind": "class",
Expand Down Expand Up @@ -7527,7 +7527,7 @@
{
"_type": "tag",
"name": "Token",
"path": "./aura_lang/lexer.py",
"path": "./languages/aura/lexer.py",
"language": "Python",
"line": 3,
"kind": "class",
Expand Down Expand Up @@ -7653,7 +7653,7 @@
{
"_type": "tag",
"name": "AST",
"path": "./aura_lang/ast.py",
"path": "./languages/aura/ast.py",
"language": "Python",
"line": 3,
"kind": "class",
Expand Down Expand Up @@ -7986,7 +7986,7 @@
{
"_type": "tag",
"name": "Parser",
"path": "./aura_lang/parser.py",
"path": "./languages/aura/parser.py",
"language": "Python",
"line": 26,
"kind": "class",
Expand Down
10 changes: 10 additions & 0 deletions languages/aal/interpreter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def interpret(aal_data):
"""
Interprets a parsed AAL data structure.
"""
for doc in aal_data:
if "protocol_id" not in doc:
raise ValueError("Missing 'protocol_id' in AAL data.")
if "rules" not in doc:
raise ValueError("Missing 'rules' in AAL data.")
return True
8 changes: 8 additions & 0 deletions languages/aal/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import yaml

def parse(aal_file):
"""
Parses an AAL file and returns a list of Python dictionaries.
"""
with open(aal_file, 'r') as f:
return list(yaml.safe_load_all(f))
15 changes: 15 additions & 0 deletions languages/aal/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import unittest
from . import parser
from . import interpreter

class TestAAL(unittest.TestCase):

def test_parse_and_interpret(self):
"""
Tests that the AAL parser and interpreter can successfully parse and interpret an AAL file.
"""
aal_data = parser.parse("languages/aal/logging-verification.aal")
self.assertTrue(interpreter.interpret(aal_data))

if __name__ == '__main__':
unittest.main()
Empty file added languages/appl/__init__.py
Empty file.
File renamed without changes.
6 changes: 3 additions & 3 deletions interpreter.py → languages/appl/interpreter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from appl_ast import (
from .ast import (
Term,
Var,
Int,
Expand All @@ -19,14 +19,14 @@
Cons,
AST,
)
from planning import (
from .planning import (
create_action,
create_goal,
create_state,
apply_action,
is_goal,
)
from parser import parse
from .parser import parse


class InterpError(Exception):
Expand Down
2 changes: 1 addition & 1 deletion parser.py → languages/appl/parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from appl_ast import *
from .ast import *

class Parser:
def __init__(self, tokens):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test.appl.py → languages/appl/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from appl_ast import *
from .ast import *

# A simple APPL program: let !x = !5 in x * x
# This will be translated to LFI ILL.
Expand Down
6 changes: 3 additions & 3 deletions test_interpreter.py → languages/appl/test_interpreter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from appl_ast import (
from .ast import (
Int,
String,
Bool,
Expand All @@ -19,8 +19,8 @@
TInt,
TString,
)
from interpreter import interpret, InterpError, Closure
from planning import Action
from .interpreter import interpret, InterpError, Closure
from .planning import Action


class TestInterpreter(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions test_parser.py → languages/appl/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from appl_ast import (
from .ast import (
Int,
String,
Bool,
Expand All @@ -19,7 +19,7 @@
TInt,
TString,
)
from parser import parse
from .parser import parse


class TestParser(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions test_type_checker.py → languages/appl/test_type_checker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from appl_ast import (
from .ast import (
Int,
String,
Bool,
Expand All @@ -23,7 +23,7 @@
TProd,
TSum,
)
from type_checker import type_check, TypeCheckError
from .type_checker import type_check, TypeCheckError


class TestTypeChecker(unittest.TestCase):
Expand Down
41 changes: 2 additions & 39 deletions tooling/appl_to_lfi_ill.py → languages/appl/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
import sys
import os
import importlib.util
import appl_ast
import lfi_ill

# Add the root directory to the Python path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from . import ast as appl_ast
from lfi_ill import ast as lfi_ill

class ApplToLfiIllCompiler:
def __init__(self):
Expand Down Expand Up @@ -94,37 +91,3 @@ def compile_type(self, type_):
Translates APPL types to LFI ILL types.
"""
return str(type_)

def main():
parser = argparse.ArgumentParser(description="Compile APPL code to LFI ILL.")
parser.add_argument("file", help="The APPL file to compile (as a Python file).")
args = parser.parse_args()

try:
module_name = os.path.splitext(os.path.basename(args.file))[0]
spec = importlib.util.spec_from_file_location(module_name, args.file)
appl_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(appl_module)
appl_ast_node = appl_module.APPL_AST
except FileNotFoundError:
print(f"Error: File not found at {args.file}")
return
except Exception as e:
print(f"Error loading APPL module from file: {e}")
return

compiler = ApplToLfiIllCompiler()
lfi_ill_ast = compiler.compile(appl_ast_node.term)

print("--- COMPILED LFI ILL AST ---")
print(repr(lfi_ill_ast))

output_filename = args.file.replace(".py", ".lfi_ill")
with open(output_filename, 'w') as f:
f.write(repr(lfi_ill_ast))

print(f"\nSuccessfully compiled to {output_filename}")


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion type_checker.py → languages/appl/type_checker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from appl_ast import (
from .ast import (
AST, App, Bool, Case, Cons, Fun, Inl, Inr, Int, Let, LetBang, LetPair, Nil,
Pair, Promote, String, TAction, TBool, TExponential, TFun, TGoal, TInt,
TList, TProd, TState, TString, TSum, TTerm, TUnit, Term, Type, Unit, Var
Expand Down
File renamed without changes.
Empty file added languages/aura/__init__.py
Empty file.
File renamed without changes.
27 changes: 1 addition & 26 deletions aura_lang/interpreter.py → languages/aura/interpreter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from aura_lang import ast
from . import ast
import re
import json

Expand Down Expand Up @@ -32,25 +32,6 @@ def set(self, name, val):
self.store[name] = val
return val

# --- Agent Tooling Bridge ---

# --- Agent Tooling Bridge ---

def _placeholder_agent_call_tool(tool_name, *args):
"""
Placeholder for calling the agent's real tools.
This will be replaced by a real implementation provided by the executor.
"""
print(f"[Aura Interpreter]: Tool call to '{tool_name}' with args {args} is not yet implemented.")
if tool_name == "hdl_prover.prove_sequent":
# Return a mock value for now
return True
return None

# This can be overwritten by the executor.
# By default, it's a placeholder. The aura_executor.py script
# will replace this with a real implementation.
agent_call_tool = _placeholder_agent_call_tool

# --- Interpreter ---

Expand Down Expand Up @@ -183,11 +164,6 @@ def apply_function(fn, args):
# The arguments are already Aura Objects, so we can pass them directly.
return fn.fn(*args)

class Agent(Object):
def __init__(self):
self.value = self
self.call_tool = Builtin(agent_call_tool)

def len_builtin(*args):
if len(args) != 1:
return None
Expand All @@ -199,6 +175,5 @@ def len_builtin(*args):
return None

BUILTINS = {
"agent": Agent(),
"len": Builtin(len_builtin),
}
File renamed without changes.
4 changes: 2 additions & 2 deletions aura_lang/parser.py → languages/aura/parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from aura_lang.lexer import Lexer, Token
from aura_lang.ast import (
from .lexer import Lexer, Token
from .ast import (
Program, Statement, Expression, LetStatement, ReturnStatement,
ExpressionStatement, Identifier, IntegerLiteral, StringLiteral,
InfixExpression, CallExpression, FunctionDefinition, BlockStatement,
Expand Down
2 changes: 2 additions & 0 deletions tests/test.aura
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// tests/test.aura
print("hello from aura");
Loading