Goose  Diff

Differences From Artifact [2e87d6af79]:

  • File bs/empathy.cpp — part of check-in [093794896f] at 2019-01-12 13:11:32 on branch trunk — Some preliminary work on functions. (user: achavasse size: 1983)

To Artifact [d13d3009df]:

  • File bs/empathy.cpp — part of check-in [a9ae189d74] at 2019-01-13 15:59:14 on branch trunk — Lexer: added some throw away test code, fixed a couple of bugs. (user: achavasse size: 710)

1
2

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

50
51

52
53



54
55
56

57
58
59
60
61
62
#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 testHole1( "A"_sid );
    sema::Hole testHole2( 1234 );
    auto holeExpr1 = sema::HoleToIRExpr( testHole1 );
    cout << holeExpr1 << endl;
    auto holeExpr2 = sema::HoleToIRExpr( testHole2 );
    cout << holeExpr2 << endl;

    auto testHole = sema::HoleFromIRExpr( holeExpr1 );
    cout << testHole.has_value() << endl;
    cout << sema::HoleToIRExpr( *testHole ) << endl;

    testHole = sema::HoleFromIRExpr( holeExpr2 );
    cout << testHole.has_value() << endl;
    cout << sema::HoleToIRExpr( *testHole ) << endl;


    cout << "\n===================================\n\n";


    sema::FunDecl fdecl1( TVEC(), TSID( retType ), TVEC() );




    auto ruleSet = make_shared< sema::FunRuleSet >();
    auto fun = sema::BuildFun( FunDeclToIRExpr( fdecl1 ), ruleSet );


    if( fun )
        cout << *fun << endl;

    return EXIT_SUCCESS;
}


>








<
<
|
<
<
<
<
<
<
<
<
<
<

<
|
<
<
|
<
<
<
|
|
|
<
<
<
<
<
<
|
<
<
<

<
|
<
>

<
>
|
<
>
>
>

<
<
>
|
<
<



1
2
3
4
5
6
7
8
9
10
11


12










13

14


15



16
17
18






19



20

21

22
23

24
25

26
27
28
29


30
31


32
33
34
#include "ir/ir.h"
#include "sema/sema.h"
#include "lexer/lexer.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 filename = make_shared< string >( "em/lib/empathy.em" );












    ifstream sourcefile( filename->c_str() );


    if( !sourcefile.good() )



    {
        cout << "can't open '" << *filename << "'\n";
        return EXIT_FAILURE;






    }





    // Simple lexer test

    Lexer lex( sourcefile, filename );


    while( !lex.eos() )
    {

        auto tok = lex.consume();
        if( !tok )
            break;



        cout << *tok << endl;
    }



    return EXIT_SUCCESS;
}