diff --git a/hy/compilers/__init__.py b/hy/compilers/__init__.py index 2f8a9c5..e8b1e34 100644 --- a/hy/compilers/__init__.py +++ b/hy/compilers/__init__.py @@ -18,7 +18,15 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +from abc import ABCMeta, abstractmethod + class HyCompiler(object): + __metaclass__ = ABCMeta + def __init__(self): pass + + @abstractmethod + def compile(self, tree): + pass diff --git a/hy/compilers/ast.py b/hy/compilers/ast.py index 437acf2..6e6967c 100644 --- a/hy/compilers/ast.py +++ b/hy/compilers/ast.py @@ -18,5 +18,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +from hy.compilers import HyCompiler +class HyASTCompiler(HyCompiler): + pass diff --git a/setup.py b/setup.py index 73be4d8..78ff753 100755 --- a/setup.py +++ b/setup.py @@ -37,6 +37,7 @@ setup( 'hy', 'hy.lex', 'hy.models', + 'hy.compilers', ], author="Paul Tagliamonte", author_email="tag@pault.ag", diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/compilers/__init__.py b/tests/compilers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/compilers/test_ast.py b/tests/compilers/test_ast.py new file mode 100644 index 0000000..54f2577 --- /dev/null +++ b/tests/compilers/test_ast.py @@ -0,0 +1,28 @@ +# Copyright (c) 2012 Paul Tagliamonte +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +from hy.compilers.ast import HyASTCompiler +from hy.lex import tokenize + + +def test_ast_expression(): + """ Test AST --> Expression conversion """ + compiler = HyASTCompiler() + code = compiler.compile(tokenize("(foo bar)")) diff --git a/tests/lex/__init__.py b/tests/lex/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_lex.py b/tests/lex/test_lex.py similarity index 100% rename from tests/test_lex.py rename to tests/lex/test_lex.py