Skip to content

Commit

Permalink
Symbol Resolver
Browse files Browse the repository at this point in the history
* added some basic tests for the symbol resolver pass
  - related to ref sealangdotorg/sea#22
  • Loading branch information
ppaulweber committed Apr 3, 2017
1 parent 050b375 commit 943267c
Show file tree
Hide file tree
Showing 10 changed files with 363 additions and 0 deletions.
35 changes: 35 additions & 0 deletions uts/symtbl/builtin_same_name.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//


CASM init foo

rule foo =
{
assert( true )

assert( true, "this is a true assertion" )

program( self ) := undef
}
37 changes: 37 additions & 0 deletions uts/symtbl/derived.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//


CASM init foo

function bar : -> Integer

derived qux -> Integer = bar

rule foo =
{
bar := qux + qux

program( self ) := undef
}
35 changes: 35 additions & 0 deletions uts/symtbl/enumeration.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//


CASM init foo

enum ABC = { A, B, C }

rule foo =
{
print( A )

program( self ) := undef
}
37 changes: 37 additions & 0 deletions uts/symtbl/error/unresolved_identifier.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//


CASM init foo

rule foo =
{
bar //@ERROR( ? )
qux //@ERROR( ? )

call bar //@ERROR( ? )
call qux //@ERROR( ? )

program( self ) := undef
}
35 changes: 35 additions & 0 deletions uts/symtbl/function.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//


CASM init foo

function bar : -> Integer

rule foo =
{
bar := bar + bar

program( self ) := undef
}
36 changes: 36 additions & 0 deletions uts/symtbl/let.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//


CASM init foo

rule foo =
{
let bar = 1 in
{
print( bar )
}

program( self ) := undef
}
41 changes: 41 additions & 0 deletions uts/symtbl/let_multiple.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//


CASM init foo

rule foo =
{
let bar = 1 in
{
print( bar )
}

let bar = 2 in
{
print( bar )
}

program( self ) := undef
}
38 changes: 38 additions & 0 deletions uts/symtbl/rule.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//


CASM init foo

rule bar =
{
skip
}

rule foo =
{
call bar

call (*@bar)()
}
38 changes: 38 additions & 0 deletions uts/symtbl/rule_parameters.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//


CASM init foo

rule bar( qux : Integer ) =
{
print( qux )
}

rule foo =
{
call bar

call (*@bar)()
}
31 changes: 31 additions & 0 deletions uts/symtbl/trivial.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//


CASM init foo

rule foo =
{
program( self ) := undef
}

0 comments on commit 943267c

Please sign in to comment.