merge.abs

来自「tiger编译器的Java实现」· ABS 代码 · 共 406 行

ABS
406
字号
 LetExp(  DecList(   TypeDec(any,    RecordTy(     Fieldlist(      any      int,      true,      Fieldlist()))),   DecList(    VarDec(buffer,     CallExp(getchar,      ExpList()),     true),    DecList(     FunctionDec(readint      Fieldlist(       any       any,       true,       Fieldlist()),      int      LetExp(       DecList(        VarDec(i,         IntExp(0),         true),        DecList(         FunctionDec(isdigit          Fieldlist(           s           string,           true,           Fieldlist()),          int          OpExp(           GE,           OpExp(            GE,            CallExp(ord,             ExpList(              varExp(               SimpleVar(buffer)))),            CallExp(ord,             ExpList(              StringExp(0)))),           OpExp(            LE,            CallExp(ord,             ExpList(              varExp(               SimpleVar(buffer)))),            CallExp(ord,             ExpList(              StringExp(9))))),          FunctionDec(skipto           Fieldlist(),           WhileExp(            OpExp(             GE,             OpExp(              EQ,              varExp(               SimpleVar(buffer)),              StringExp( )),             OpExp(              EQ,              varExp(               SimpleVar(buffer)),              StringExp())),            AssignExp(             SimpleVar(buffer),             CallExp(getchar,              ExpList()))),           FunctionDec())),         DecList())),       SeqExp(        ExpList(         CallExp(skipto,          ExpList()),         ExpList(          AssignExp(           FieldVar(            SimpleVar(any),            any),           CallExp(isdigit,            ExpList(             varExp(              SimpleVar(buffer))))),          ExpList(           WhileExp(            CallExp(isdigit,             ExpList(              varExp(               SimpleVar(buffer)))),            SeqExp(             ExpList(              AssignExp(               SimpleVar(i),               OpExp(                MINUS,                OpExp(                 PLUS,                 OpExp(                  MUL,                  varExp(                   SimpleVar(i)),                  IntExp(10)),                 CallExp(ord,                  ExpList(                   varExp(                    SimpleVar(buffer))))),                CallExp(ord,                 ExpList(                  StringExp(0))))),              ExpList(               AssignExp(                SimpleVar(buffer),                CallExp(getchar,                 ExpList())))))),           ExpList(            varExp(             SimpleVar(i)))))))),      FunctionDec()),     DecList(      TypeDec(list,       RecordTy(        Fieldlist(         first         int,         true,         Fieldlist(          rest          list,          true,          Fieldlist())))),      DecList(       FunctionDec(readlist        Fieldlist(),        list        LetExp(         DecList(          VarDec(any,           RecordExp(any,            FieldExpList(any,             IntExp(0),             FieldExpList())),           true),          DecList(           VarDec(i,            CallExp(readint,             ExpList(              varExp(               SimpleVar(any)))),            true),           DecList())),         SeqExp(          ExpList(           IfExp(            varExp(             FieldVar(              SimpleVar(any),              any)),            RecordExp(list,             FieldExpList(first,              varExp(               SimpleVar(i)),              FieldExpList(rest,               CallExp(readlist,                ExpList()),               FieldExpList()))),            NilExp())))),        FunctionDec(merge         Fieldlist(          a          list,          true,          Fieldlist(           b           list,           true,           Fieldlist())),         list         IfExp(          OpExp(           EQ,           varExp(            SimpleVar(a)),           NilExp()),          varExp(           SimpleVar(b)),          IfExp(           OpExp(            EQ,            varExp(             SimpleVar(b)),            NilExp()),           varExp(            SimpleVar(a)),           IfExp(            OpExp(             LT,             varExp(              FieldVar(               SimpleVar(a),               first)),             varExp(              FieldVar(               SimpleVar(b),               first))),            RecordExp(list,             FieldExpList(first,              varExp(               FieldVar(                SimpleVar(a),                first)),              FieldExpList(rest,               CallExp(merge,                ExpList(                 varExp(                  FieldVar(                   SimpleVar(a),                   rest)),                 ExpList(                  varExp(                   SimpleVar(b))))),               FieldExpList()))),            RecordExp(list,             FieldExpList(first,              varExp(               FieldVar(                SimpleVar(b),                first)),              FieldExpList(rest,               CallExp(merge,                ExpList(                 varExp(                  SimpleVar(a)),                 ExpList(                  varExp(                   FieldVar(                    SimpleVar(b),                    rest))))),               FieldExpList())))))),         FunctionDec(printint          Fieldlist(           i           int,           true,           Fieldlist()),          LetExp(           DecList(            FunctionDec(f             Fieldlist(              i              int,              true,              Fieldlist()),             IfExp(              OpExp(               GT,               varExp(                SimpleVar(i)),               IntExp(0)),              SeqExp(               ExpList(                CallExp(f,                 ExpList(                  OpExp(                   DIV,                   varExp(                    SimpleVar(i)),                   IntExp(10)))),                ExpList(                 CallExp(print,                  ExpList(                   CallExp(chr,                    ExpList(                     OpExp(                      PLUS,                      OpExp(                       MINUS,                       varExp(                        SimpleVar(i)),                       OpExp(                        MUL,                        OpExp(                         DIV,                         varExp(                          SimpleVar(i)),                         IntExp(10)),                        IntExp(10))),                      CallExp(ord,                       ExpList(                        StringExp(0)))))))))))),             FunctionDec()),            DecList()),           SeqExp(            ExpList(             IfExp(              OpExp(               LT,               varExp(                SimpleVar(i)),               IntExp(0)),              SeqExp(               ExpList(                CallExp(print,                 ExpList(                  StringExp(-))),                ExpList(                 CallExp(f,                  ExpList(                   OpExp(                    GE,                    IntExp(0),                    varExp(                     SimpleVar(i)))))))),              IfExp(               OpExp(                GT,                varExp(                 SimpleVar(i)),                IntExp(0)),               CallExp(f,                ExpList(                 varExp(                  SimpleVar(i)))),               CallExp(print,                ExpList(                 StringExp(0)))))))),          FunctionDec(printlist           Fieldlist(            l            list,            true,            Fieldlist()),           IfExp(            OpExp(             EQ,             varExp(              SimpleVar(l)),             NilExp()),            CallExp(print,             ExpList(              StringExp())),            SeqExp(             ExpList(              CallExp(printint,               ExpList(                varExp(                 FieldVar(                  SimpleVar(l),                  first)))),              ExpList(               CallExp(print,                ExpList(                 StringExp( ))),               ExpList(                CallExp(printlist,                 ExpList(                  varExp(                   FieldVar(                    SimpleVar(l),                    rest))))))))),           FunctionDec())))),       DecList(        VarDec(list1,         CallExp(readlist,          ExpList()),         true),        DecList(         VarDec(list2,          SeqExp(           ExpList(            AssignExp(             SimpleVar(buffer),             CallExp(getchar,              ExpList())),            ExpList(             CallExp(readlist,              ExpList())))),          true),         DecList()))))))),  SeqExp(   ExpList(    CallExp(printlist,     ExpList(      CallExp(merge,       ExpList(        varExp(         SimpleVar(list1)),        ExpList(         varExp(          SimpleVar(list2))))))))))

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?