Goose  Artifact [9dd284bdd1]

Artifact 9dd284bdd1be779fa3daaf9c7909b719582eae0463cb61f4c4fe16d19cceda0c:

  • File bs/empathy.cpp — part of check-in [1abcc3571d] at 2018-11-25 22:53:08 on branch trunk —
    • ir: added an algorithm to easily check and decompose an expression according to a specification.
    • sema: rewrote Hole::FromIRExpr() using the above.
    (user: achavasse size: 1410)

#include "ir/ir.h"
#include "sema/sema.h"

using namespace std;
using namespace empathy;
using namespace empathy::util;

int main( int argc, char** argv )
{
    // Just a dumping place for simple test code for now.
    auto gg = TVEC( TSTR( "bar" ), TSID( gg ), VECOFLENGTH( N ), REPEAT( ANYTERM( U ) ) );
    cout << gg << endl;

    ir::Trie<> testTrie;
    testTrie = Merge( testTrie, gg );
    testTrie = Merge( testTrie, TVEC( TSID( blah ), TSTR( "bar" ) ) );
    testTrie = Merge( testTrie, TVEC( TSID( foo ), TSTR( "bar" ) ) );
    testTrie = Merge( testTrie, TVEC( TSID( blah ), TSTR( "meh" ) ) );
    auto testTrie2 = testTrie;
    testTrie = Merge( testTrie, TSTR( "bar" ) );
    testTrie = Merge( testTrie, TSTR( "foo" ) );
    testTrie = Merge( testTrie, TVEC() );
    testTrie = Merge( testTrie, TVEC( TSID( gg ) ) );

    ir::GraphVizDump( "dump2.dot", testTrie );

    for( auto&& t : Enumerate( testTrie ) )
        cout << t << endl;

    cout << Compare( testTrie, testTrie2 ) << endl;
    cout << Compare( testTrie2, testTrie2 ) << endl;
    cout << Compare( testTrie, testTrie ) << endl;

    cout << "\n";

    sema::Hole testHole( "A"_sid, 1 );
    auto holeExpr = testHole.toIRExpr();
    cout << holeExpr << endl;

    auto testHole2 = sema::Hole::FromIRExpr( holeExpr );
    cout << testHole2.has_value() << endl;
    cout << testHole2->toIRExpr() << endl;

    return EXIT_SUCCESS;
}