├── .gitignore
├── CMakeLists.txt
├── LICENSE
├── README.md
├── bliss.cpp
├── doc
├── bliss-article.pdf
├── bliss.xml
├── bliss2.xml
├── blsalphai64dif.md
├── blsalphai64dif.mem
├── blslref.pdf
├── blsvaxalphadif.md
└── blsvaxalphadif.mem
├── include
└── bliss
│ ├── AST
│ ├── AttributeAST.h
│ ├── BaseAST.h
│ ├── BindingAST.h
│ ├── BlockAST.h
│ ├── CompileTimeAST.h
│ ├── ConditionHandlingAST.h
│ ├── ConstantAST.h
│ ├── ControlAST.h
│ ├── DataAST.h
│ ├── DeclarationAST.h
│ ├── ExecutableFuncAST.h
│ ├── ExprAST.h
│ ├── IncludeAST.h
│ ├── LexicalAST.h
│ ├── LinkageAST.h
│ ├── MacroAST.h
│ ├── ModuleAST.h
│ ├── OperatorAST.h
│ ├── PrimaryAST.h
│ ├── RoutineAST.h
│ ├── SpecialAST.h
│ └── StructureAST.h
│ ├── Basic
│ ├── CommonInclude.h
│ ├── FileManager.h
│ ├── InputChar.h
│ ├── InputFile.h
│ └── Lister.h
│ ├── Driver
│ └── Driver.h
│ └── FrontEnd
│ ├── Keyword.h
│ ├── Lexer.h
│ └── Parser.h
├── lib
├── Basic
│ ├── CMakeLists.txt
│ ├── FileManager.cpp
│ └── InputFile.cpp
├── Driver
│ ├── CMakeLists.txt
│ └── Driver.cpp
└── FrontEnd
│ ├── CMakeLists.txt
│ ├── Lexer.cpp
│ └── Parser.cpp
├── nbproject
├── configurations.xml
├── private
│ ├── c_standard_headers_indexer.c
│ ├── configurations.xml
│ ├── cpp_standard_headers_indexer.cpp
│ ├── launcher.properties
│ └── private.xml
└── project.xml
└── tests
├── AST
└── module_test_01.b64
├── expression
├── controlexp.bli
├── operators.bli
└── structures.bli
├── lexical
├── lexfuncs1.bli
├── lexfuncs2.bli
├── literals.bli
├── macros.bli
└── names.bli
├── runtests.py
├── testharness.c
└── testharness.req
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/c++
3 | # Edit at https://www.gitignore.io/?templates=c++
4 |
5 | ### C++ ###
6 | # Prerequisites
7 | *.d
8 |
9 | # Compiled Object files
10 | *.slo
11 | *.lo
12 | *.o
13 | *.obj
14 |
15 | # Precompiled Headers
16 | *.gch
17 | *.pch
18 |
19 | # Compiled Dynamic libraries
20 | *.so
21 | *.dylib
22 | *.dll
23 |
24 | # Fortran module files
25 | *.mod
26 | *.smod
27 |
28 | # Compiled Static libraries
29 | *.lai
30 | *.la
31 | *.a
32 | *.lib
33 |
34 | # Executables
35 | *.exe
36 | *.out
37 | *.app
38 |
39 | # End of https://www.gitignore.io/api/c++
40 | build/
41 |
42 | # Netbeans project folder
43 | nbproject/
44 |
45 | /doc/blsalphai64dif.pdf
46 | /doc/blsvaxalphadif.pdf
47 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required (VERSION 3.10)
2 |
3 | set(CMAKE_C_COMPILER clang)
4 | set(CMAKE_CXX_COMPILER clang++)
5 |
6 | project (bliss)
7 |
8 | set(CMAKE_CXX_FLAGS "-g -O0 -std=c++11")
9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE")
10 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS")
12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_LIMIT_MACROS")
13 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${${CMAKE_PROJECT_NAME}_SOURCE_DIR}/include/bliss")
14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/lib/llvm-8/include")
15 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
16 |
17 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/lib/llvm-8/lib -lLLVM-8")
18 |
19 | add_subdirectory(lib/Basic)
20 | add_subdirectory(lib/FrontEnd)
21 | add_subdirectory(lib/Driver)
22 |
23 | add_executable(bliss bliss.cpp)
24 |
25 | add_dependencies(bliss
26 | Driver
27 | Basic
28 | FrontEnd
29 | )
30 |
31 | target_link_libraries(bliss
32 | Driver
33 | Basic
34 | FrontEnd
35 | )
36 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | README for the BLISS-LLVM Compiler
2 | ==================================
3 |
4 | This is the source package for the BLISS compiler, a portable
5 | cross-compiler for the BLISS programming language.
6 | Visit the [project website](http://github.com/JonathanBelanger/blisscpp)
7 | for more information about BLISS.
8 |
9 | Why a BLISS compiler
10 | --------------------
11 |
12 | There are a number of reasons why I wanted to write a BLISS compiler. The
13 | top ones are:
14 |
15 | * When I worked at DEC on the IBM Interconnect product set, the OpenVMS versions
16 | of these products, all 14 of them, were written in BLISS.
17 | * I also wrote and SDL compiler, OpenSDL, that will eventually generate BLISS
18 | REQUIRE output files, and I wanted a way to be able to test them.
19 | * I love the BLISS way of defining MACROs. The fact that a MACRO can refer to
20 | itself, as well as other MACROs and vice versa, is incredibly powerful.
21 | * I have never written a compiler before and was recently introduced to LLVM,
22 | so it seems like a good place to start.
23 |
24 | Available BLISS compilers
25 | -------------------------
26 |
27 | There are a few BLISS compilers out there:
28 |
29 | 1. The original, which only runs on OpenVMS (VAX, Alpha, and IA64), [OpenVMS Freeware CD V8.0](https://www.digiater.nl/openvms/freeware/v80/bliss/)
30 | 2. A FreeVMS Portable BLISS for GCC - ftp://freevms.nvg.org/pub/vms/freevms/bliss
31 | 3. One implemented by VMS Sofware - [VSI June 2019 OpenVMS Roadmap](http://vmssoftware.com/pdfs/VSI_Roadmap_20190722.pdf)).
32 | 4. One written by Matt Madison [The BLISS-M Compiler Project](http://madisongh.github.io/blissc)
33 |
34 | Current Status
35 | --------------
36 |
37 | Work in progress. This is, in effect, a re-implementation of the BLISS-M compiler
38 | project for more information. BLISS-M was written in C and to LLVM 3.9-5.0. This
39 | implementation will be written in C++ and to LLVM 8.0-9.0 (and possibly 10.0) and
40 | support any available LLVM enhancements.
41 |
42 | Prerequisites
43 | -------------
44 |
45 | Known to build Ubuntu 19.04 and later (64-bit).
46 |
47 | The code generator uses LLVM 8.0, 9.0 or 10.0, which you can download
48 | directly from llvm.org. On Ubuntu systems, you can install one
49 | of the llvm-dev packages using apt.
50 |
51 | The build system uses CMake 3.13 or later.
52 |
53 | Building the compiler
54 | ---------------------
55 |
56 | 1. Clone [the repository](https://github.com/JonathanBelanger/blisscpp.git).
57 | 2. cd to the top-level source directory and create a build directory.
58 | 3. cd to your build directory.
59 | 4. Run `cmake ..`.
60 | 5. Run `make` to build the compiler.
61 | 6. Run `make check` to test the built compiler.
62 |
63 |
64 | Running the compiler
65 | --------------------
66 |
67 | The build will produce a program called **bliss** in your build
68 | directory. Run `./bliss --help` for a description of the arguments
69 | and options.
70 |
71 |
72 | Contributions
73 | -------------
74 |
75 | There is a lot more yet to do on this project! If you are interested
76 | in contributing, contact me (JonathanBelanger on GitHub, or by e-mail at
77 | jbelanger _at_ rochester _dot_ rr _dot_ com).
78 |
79 | License
80 | -------
81 | All sources are released under the GPL 3.0 license. See the
82 | [LICENSE](https://github.com/JonathanBelanger/blisscpp/blob/master/LICENSE)
83 | file for the license text.
84 |
--------------------------------------------------------------------------------
/bliss.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: Reader.cpp
20 | * Author: Jonathan D. Belanger
21 | *
22 | * V01.000 Jonathan D. Belanger August 31, 2019, 3:02 PM
23 | * Initially created.
24 | *
25 | * V01.001 Jonathan D. Belanger September 1, 2019, 1:55 PM
26 | * Introduced the following classes:
27 | * InputChar - contains information about a single character, including
28 | * its character class.
29 | * InputFile - contains the code to read a single character from a file
30 | * and return it back to the caller. Also, handles character
31 | * classification and end of file detection.
32 | * FileManager - contains the code to be able to open multiple files and
33 | * close them in the reverse order in which they were opened.
34 | * The next step will be to move these into their own include and module
35 | * files.
36 | */
37 | #include "Driver/Driver.h"
38 |
39 | using namespace std;
40 | using namespace bliss;
41 |
42 | Driver *Driver::driver = nullptr;
43 |
44 | /*
45 | * This function is called to test the input file processing and character
46 | * classification code.
47 | */
48 | int main(int argc, char** argv)
49 | {
50 | Driver *driver = Driver::get();
51 | vector files = {"/home/belanger/projects/bliss/tests/AST/module_test_01.b64"};
52 |
53 | if (driver->setFiles(&files) == true)
54 | {
55 | driver->mainLoop();
56 | }
57 |
58 | #if 0
59 | if (fileMgr->pushFile("/home/belanger/projects/bliss/tests/lexical/lexfuncs1.bli") ==
60 | true)
61 | {
62 | while(lex->getNext())
63 | {
64 | switch(lex->getType())
65 | {
66 | case Lexer::LTUnknown:
67 | cout << "Got an unknown Lexeme:\n" <<
68 | " c: " << lex->getChar() << "\n" <<
69 | " string: " << lex->getString() << "\n" <<
70 | " value: " << lex->getValue() << "\n";
71 | break;
72 |
73 | case Lexer::LTKeyword:
74 | cout << "Got a keyword:\n" <<
75 | " keyword: " << lex->getKeyword() << "\n" <<
76 | " reserved: " << (lex->getReserved() ? "True\n" : "False\n") <<
77 | " string: " << lex->getString() << "\n";
78 | break;
79 |
80 | case Lexer::LTPredeclared:
81 | cout << "Got a predeclared keyword:\n" <<
82 | " keyword: " << lex->getKeyword() << "\n" <<
83 | " reserved: " << (lex->getReserved() ? "True\n" : "False\n") <<
84 | " string: " << lex->getString() << "\n";
85 | break;
86 |
87 | case Lexer::LTExplicitDeclared:
88 | cout << "Got an explicit declared keyword:\n" <<
89 | " keyword: " << lex->getKeyword() << "\n" <<
90 | " reserved: " << (lex->getReserved() ? "True\n" : "False\n") <<
91 | " string: " << lex->getString() << "\n";
92 | break;
93 |
94 | case Lexer::LTDecimalLiteral:
95 | cout << "Got a decimal literal:\n" <<
96 | " value: " << lex->getValue() << "\n";
97 | break;
98 |
99 | case Lexer::LTQuotedString:
100 | cout << "Got a quoted string:\n" <<
101 | " value: " << lex->getString() << "\n";
102 | break;
103 |
104 | case Lexer::LTOperator:
105 | cout << "Got an operator:\n" <<
106 | " char: " << lex->getChar() << "\n";
107 | break;
108 |
109 | case Lexer::LTPunctuation:
110 | cout << "Got a punctuation:\n" <<
111 | " char: " << lex->getChar() << "\n";
112 | break;
113 |
114 | case Lexer::LTLinemark:
115 | cout << "Got a line mark:\n";
116 | break;
117 |
118 | case Lexer::LTTrailingComment:
119 | cout << "Got a trailing comment:\n" <<
120 | " string: " << lex->getString() << "\n";
121 | break;
122 |
123 | case Lexer::LTEmbeddedComment:
124 | cout << "Got a embedded comment:\n" <<
125 | " string: " << lex->getString() << "\n";
126 | break;
127 |
128 | case Lexer::LTPercentSign:
129 | cout << "Got a percent sign:\n" <<
130 | " char: " << lex->getChar() << "\n";
131 | break;
132 | }
133 | }
134 | fileMgr->popFile();
135 | }
136 | #endif
137 | return 0;
138 | }
139 |
--------------------------------------------------------------------------------
/doc/bliss-article.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JonathanBelanger/bliss/8ec1007fb4a4f5c815c9f7a7997e2aa9aeb684b0/doc/bliss-article.pdf
--------------------------------------------------------------------------------
/doc/blslref.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JonathanBelanger/bliss/8ec1007fb4a4f5c815c9f7a7997e2aa9aeb684b0/doc/blslref.pdf
--------------------------------------------------------------------------------
/include/bliss/AST/BaseAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: BaseAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 21, 2019, 3:43 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_BASEAST_H
26 | #define LLVM_BLISS_BASEAST_H
27 |
28 | using namespace std;
29 |
30 | namespace bliss
31 | {
32 |
33 | /*
34 | * This structure is to hold the starting and ending line and column
35 | * information associated with a particular AST node.
36 | */
37 | typedef struct
38 | {
39 | uint32_t startLine;
40 | uint32_t startColumn;
41 | uint32_t endLine;
42 | uint32_t endColumn;
43 | } SourceLocation;
44 |
45 | /*
46 | * These structures define the various layouts of the descriptor structure.
47 | * The first one is the 32-bit version of the descriptor, and is used when
48 | * compiling for a 32-bit operating system. The second one is the 64-bit
49 | * version, and is used when compiling for a 64-bit operating system.
50 | */
51 | typedef struct
52 | {
53 | uint16_t dsc_l_length;
54 | uint8_t dsc_w_type;
55 | uint8_t dsc_w_class;
56 | uint32_t dsc_a_pointer;
57 | } DSC32_DESCRIPTOR;
58 | typedef struct
59 | {
60 | uint32_t dsc_l_length;
61 | uint16_t dsc_w_dtype;
62 | uint16_t dsc_w_class;
63 | uint64_t dsc_a_pointer;
64 | } DSC64_DESCRIPTOR;
65 |
66 | /*
67 | * BaseAST - Base class for all other Abstract Syntax Tree classes (ASTs).
68 | */
69 | class BaseAST
70 | {
71 | public:
72 | virtual ~BaseAST() {}
73 |
74 | /*
75 | * This function is called to return the line and column number ranges
76 | * associated with this AST node.
77 | *
78 | * @return - a pointer to a structure containing the starting/ending
79 | * line/column numbers associated with the current AST node.
80 | */
81 | SourceLocation *getLocation() { return &Loc; }
82 |
83 | private:
84 | SourceLocation Loc;
85 | };
86 | }
87 |
88 | #endif /* LLVM_BLISS_BASEAST_H */
89 |
--------------------------------------------------------------------------------
/include/bliss/AST/BindingAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: BindingAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 28, 2019, 3:30 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_BINDINGAST_H
26 | #define LLVM_BLISS_BINDINGAST_H
27 |
28 | #include "AST/AttributeAST.h"
29 | #include "AST/DeclarationAST.h"
30 | #include "AST/ExprAST.h"
31 |
32 | using namespace std;
33 |
34 | namespace bliss
35 | {
36 |
37 | /*
38 | * +- literal-declaration
39 | * bound-declaration -+ external-literal-declaration
40 | * | bind-data-declaration
41 | * +- bind-routine-declaration
42 | */
43 | class BindDeclAST : public DeclarationASt
44 | {
45 | };
46 |
47 | /*
48 | * literal-declaration -+- LITERAL --------+- literal-item, ...;
49 | * +- GLOBAL LITERAL -+
50 | *
51 | * literal-item --- literal-name = literal-value -+- : literal-attribute...
52 | * +- nothing
53 | *
54 | * literal-name --- name
55 | *
56 | * literal-value --- compile-time-constant-expression
57 | *
58 | * literal-attribute -+- range-attribute
59 | * +- weak-attribute
60 | *
61 | * Predeclared Literals
62 | *
63 | * ------- ------ ------ ----------------------------------
64 | * 32-bit 64-bit
65 | * Name Value Value Significance
66 | * ------- ------ ------ ----------------------------------
67 | * %BPVAL 32 64 Bits per BLISS value (fullword)
68 | * %BPUNIT 8 8 Bits per smallest addressable unit
69 | * %BPADDR 32 64 Bits per address value
70 | * %UPVAL 4 8 Addressable units per BLISS value
71 | * (%BPVAL / %BPUNIT)
72 | * ------- ------ ------ ----------------------------------
73 | */
74 | class LiteralDeclAST : public BindDeclAST
75 | {
76 | };
77 |
78 | /*
79 | * external-literal-declaration --- EXTERNAL LITERAL external-literal-item, ...;
80 | *
81 | * external-literal-item --- literal-name -+- : literal-attribute
82 | * +- nothing
83 | */
84 | class ExternLiteralDeclAST : public BindDeclAST
85 | {
86 | };
87 |
88 | /*
89 | * bind-data-declaration -+- BIND -+- bind-data-item, ...;
90 | *
91 | * bind-data-item --- bind-data-name = data-name-value -+- : bind-data-attribute...
92 | * +- nothing
93 | *
94 | * bind-data-name --- name
95 | *
96 | * bind-data-value --- expression
97 | *
98 | * +- allocation-unit
99 | * | extension-attribute
100 | * bind-data-attribute -+ structure-attribute
101 | * | field-attribute
102 | * | volatile-attribute
103 | * +- weak-attribute
104 | */
105 | class BindDataDeclAST : public BindDeclAST
106 | {
107 | };
108 |
109 | /*
110 | * bind-routine-declaration -+- BIND ROUTINE --------+- bind-routine-item, ...;
111 | * +- GLOBAL BIND ROUTINE -+
112 | *
113 | * bind-routine-item --- bind-routine-name = routine-name-value -+- : bind-routine-attribute...
114 | * +- nothing
115 | *
116 | * bind-routine-name --- name
117 | *
118 | * routine-name-value --- expression
119 | *
120 | * +- novalue-attribute
121 | * bind-routine-attribute -+ linkage-attribute
122 | * +- weak-attribute
123 | */
124 | class BindRoutineDeclAST : public BindDeclAST
125 | {
126 | };
127 | }
128 |
129 | #endif /* LLVM_BLISS_BINDINGAST_H */
130 |
--------------------------------------------------------------------------------
/include/bliss/AST/BlockAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: BlockAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 21, 2019, 5:00 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_BLOCKAST_H
26 | #define LLVM_BLISS_BLOCKAST_H
27 |
28 | #include "AST/BaseAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * block -+- labeled-block
37 | * +- unlabeled-block
38 | *
39 | * unlabeled-block -+- BEGIN block-body END
40 | * +- block-body
41 | *
42 | * block-body -+- declaration
43 | * +- nothing
44 | * -+- block-action ...
45 | * +- nothing
46 | * -+- block-value
47 | * +- nothing
48 | *
49 | * block-action -+- expression
50 | * block-value --+
51 | */
52 | class BlockAST : public BaseAST // AKA: The unlabeled-block
53 | {
54 | };
55 |
56 | /*
57 | * labeled-block --- label:... unlabeled-block
58 | */
59 | class LabeledBlockAST : public BlockAST
60 | {
61 | private:
62 | string label; // could be a vector of strings
63 | };
64 | }
65 |
66 | #endif /* LLVM_BLISS_BLOCKAST_H */
67 |
--------------------------------------------------------------------------------
/include/bliss/AST/CompileTimeAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: CompileTimeAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 28, 2019, 4:37 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_COMPILETIMEAST_H
26 | #define LLVM_BLISS_COMPILETIMEAST_H
27 |
28 | #include "AST/DeclarationAST.h"
29 | #include "AST/ExprAST.h"
30 |
31 | using namespace std;
32 |
33 | namespace bliss
34 | {
35 |
36 | /*
37 | * compile-time-declaration --- COMPILETIME compile-time-item, ...;
38 | *
39 | * compile-time-item --- compile-time-name = compile-time-value
40 | *
41 | * compile-time-name --- name
42 | *
43 | * compile-time-value --- compile-time-constant-expression
44 | */
45 | class CompileTimeConstantAST : public DeclarationAST
46 | {
47 | };
48 | }
49 |
50 | #endif /* LLVM_BLISS_COMPILETIMEAST_H */
51 |
--------------------------------------------------------------------------------
/include/bliss/AST/ConditionHandlingAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: ConditionHandlingAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 28, 2019, 5:15 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_CONDITIONHANDLINGAST_H
26 | #define LLVM_BLISS_CONDITIONHANDLINGAST_H
27 |
28 | #include "AST/DeclarationAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * enable-declaration --- ENABLE routine-name -+- (enable-actual, ... )
37 | * +- nothing
38 | *
39 | * +- own-name
40 | * enable-actual -+ global-name
41 | * | forward-name
42 | * +- local-name
43 | *
44 | * routine-name -+
45 | * own-name |
46 | * global-name +- name
47 | * forward-name |
48 | * local-name ---+
49 | */
50 | class EnableDeclAST : public DeclarationAST
51 | {
52 | };
53 | }
54 |
55 | #endif /* LLVM_BLISS_CONDITIONHANDLINGAST_H */
56 |
--------------------------------------------------------------------------------
/include/bliss/AST/ConstantAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: ConstantAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 21, 2019, 4:40 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_CONSTANTAST_H
26 | #define LLVM_BLISS_CONSTANTAST_H
27 |
28 | #include "AST/ExprAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 | /*
35 | * compile-time-constant-expression --- expression
36 | *
37 | * Restrictions:
38 | *
39 | * A compile-time constant expression must be one of the following
40 | * expressions:
41 | * 1. A numeric-literal.
42 | * 2. A string-literal.
43 | * 3. A name that satisfies the following conditions:
44 | * a. It is declared in any bound-declaration except an EXTERNAL
45 | * literal-declaration (as described in Chapter 14).
46 | * b. It is bound to a value that is given by a compile-time
47 | * constant expression.
48 | * 4. A structure-reference that yields a compile-time constant
49 | * expression when it is expanded (as described in Chapter 11).
50 | * 5. A block that has a compile-time constant expression (and nothing
51 | * else) as its body.
52 | * 6. An operator-expression that satisfies the following conditions:
53 | * a. It is not a fetch-expression or an assignment-expression.
54 | * b. It has a compile-time constant expression as each of its
55 | * operands.
56 | * 7. An operator-expression that has the following form:
57 | * e1 -+- rela -+- e2
58 | * +- - --+
59 | * In these forms, rela is one of the relational operators for
60 | * addresses (EQLA,NEQA, and so on). Both e1 and e2 must be
61 | * link-time constant expressions; furthermore, their values must
62 | * be addresses that are relative to the same program section,
63 | * external data segment, or external routine name.
64 | * 8. An executable-function that satisfies the following conditions:
65 | * a. It is the ABS function, the SIGN function, or one of the
66 | * max or min functions.
67 | * b. It has a compile-time constant expression as each of its
68 | * parameters.
69 | * 9. A supplementary-function that satisfies certain restrictions.
70 | * Those restrictions are not given here but instead appear as part
71 | * of the definition of each supplementary-function. (For example,
72 | * Section 20.2.1.1 states that the CH$ALLOCATION function is a
73 | * compile-time constant expression if its parameters are
74 | * compile-time constant expressions.)
75 | * 10. A conditional-expression that satisfies the following
76 | * conditions:
77 | * a. It has a test that is a compile-time constant expression.
78 | * b. It has a consequence or alternative that is a compile-time
79 | * constant expression, depending on whether the test is
80 | * satisfied or fails.
81 | * 11. A case-expression that satisfies the following conditions:
82 | * a. It has a case-index that is a compile-time constant
83 | * expression.
84 | * b. It has at least one case-action that is a compile-time
85 | * constant expression; namely, that case-action that is chosen
86 | * by the value of the case-ind
87 | */
88 | class CompileTimeConstantExpr : public ExprAST
89 | {
90 | };
91 |
92 | /*
93 | * compile-time-constant-expression --- expression
94 | *
95 | * Restrictions:
96 | *
97 | * These restrictions apply to an expression after any macro-calls in the
98 | * expression have been expanded.
99 | *
100 | * A link-time constant expression must be one of the following
101 | * expressions:
102 | * 1. A compile-time-constant-expression.
103 | * 2. A PLIT.
104 | * 3. A name that is declared as one of the following:
105 | * a. OWN, GLOBAL, EXTERNAL, or FORWARD. (These are used for names
106 | * of permanently allocated data segments.)
107 | * b. ROUTINE, GLOBAL ROUTINE, EXTERNAL ROUTINE, or FORWARD
108 | * ROUTINE. (These are used for names of routine segments.)
109 | * c. EXTERNAL LITERAL. (This is used for names of literals that
110 | * are bound in other modules.)
111 | * 4. A name that satisfies the following conditions:
112 | * a. It is declared by a bound-declaration (as described in
113 | * Chapter 14).
114 | * b. It is bound to a value that is given by a
115 | * link-time-constant-expression.
116 | * 5. A structure-reference that yields a link-time constant
117 | * expression when it is expanded (as described in Chapter 11).
118 | * 6. A block that has a link-time constant expression (and nothing
119 | * else) as its body.
120 | * 7. An operator-expression that has the following form:
121 | * e1 -+- + -+- e2
122 | * +- - -+
123 | * In these forms, e1 must be a link-time constant expression and
124 | * e2 must be a compile-time constant expression.
125 | * 8. An operator-expression that has the following form:
126 | * e1 -+- rela -+- e2
127 | * +- - --+
128 | * In these forms, rela is one of the relational operators for
129 | * addresses (EQLA, NEQA, and so on). Both e1 and e2 must be
130 | * link-time constant expressions; furthermore, their values must
131 | * be addresses that are relative to the same program section,
132 | * external data segment, or external routine name.
133 | * 9. A supplementary-function that satisfies certain restrictions.
134 | * Those restrictions are not given here but appear as part of the
135 | * definition of each supplementary function. (For example, Section
136 | * 20.2.2.1 states that the CH$PTR function is a link-time constant
137 | * expression if its first parameter is a link-time constant
138 | * expression and its remaining parameters are compile-time
139 | * constant expressions.)
140 | */
141 | class LinkTimeConstantExpr : public ExprAST
142 | {
143 | };
144 | }
145 |
146 | #endif /* LLVM_BLISS_CONSTANTAST_H */
147 |
--------------------------------------------------------------------------------
/include/bliss/AST/ControlAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: ControlAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 14, 2019, 5:28 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_CONTROLAST_H
26 | #define LLVM_BLISS_CONTROLAST_H
27 |
28 | #include "AST/ExprAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * +- conditional-expression
37 | * | case-expression
38 | * control-expression -+ select-expression
39 | * | loop-expression
40 | * | exit-expression
41 | * +- return-expression
42 | */
43 | class ControlExprAST : public ExprAST
44 | {
45 | public:
46 | ControlExprAST(void *Val) : Val(Val) {}
47 |
48 | private:
49 | void* Val;
50 | };
51 |
52 | /*
53 | * conditional-expression -+- IF test THEN consequence ELSE alternative
54 | * +- IF test THEN consequence
55 | *
56 | * test --------+
57 | * consequence +- expression
58 | * alternative -+
59 | */
60 | class ConditionalExprAST : public ControlExprAST
61 | {
62 | };
63 |
64 | /*
65 | * case-expression --- CASE case-index FROM low-bound TO high-bound
66 | * SET
67 | * case-line...
68 | * TES
69 | *
70 | * case-line --- [case-label, ...]: case-action;
71 | *
72 | * +- single-value
73 | * case-label -+ low-value TO high-value
74 | * | INRANGE
75 | * +- OUTRANGE
76 | *
77 | * case-index --+- expression
78 | * case-action -+
79 | *
80 | * low-bound +
81 | * high-bound |
82 | * single-value +- compile-time-constant-expression
83 | * low-value |
84 | * high-value --+
85 | */
86 | class CaseExprAST : public ControlExprAST
87 | {
88 | };
89 |
90 | /*
91 | * select-expression -+- SELECT | SELECTA | SELECTU ---------+- select-index OF
92 | * +- SELECTONE | SELECTONEA | SELECTONEU +
93 | * SET
94 | * select-line...
95 | * TES
96 | *
97 | * select-line --- [select-label, ...]: select-action;
98 | *
99 | * +- selector
100 | * select-label -+ low-selector TO high-selector
101 | * | OTHERWISE
102 | * + ALWAYS
103 | *
104 | * select-index --+
105 | * select-action |
106 | * selector +- expression
107 | * low-selector |
108 | * high-selector -+
109 | */
110 | class SelectExprAST : public ControlExprAST
111 | {
112 | };
113 |
114 | /*
115 | * loop-expression -+- indexed-loop-expression
116 | * +- tested-loop-expression
117 | *
118 | */
119 | class LoopExprAST : public ControlExprAST
120 | {
121 | private:
122 | ExprAST LoopBody;
123 | };
124 |
125 | /*
126 | * indexed-loop-expression -+- INCR | INCRA | INCRU -+- loop-index
127 | * +- DECR | DECRA | DESCU -+
128 | * FROM initial -+--+- TO final -+--+- BY step
129 | * nothing ------+ +- nothing --+ +- nothing
130 | * DO loop-body
131 | *
132 | * loop-index --- name
133 | *
134 | * loop-body -+
135 | * initial +- expression
136 | * final |
137 | * step ------+
138 | */
139 | class IndexLoopExprAST : public LoopExprAST
140 | {
141 | };
142 |
143 | /*
144 | * tested-loop-expression -+- pre-tested-loop
145 | * +- post-tested-loop
146 | *
147 | * pre-tested-loop -+- WHILE -+- test DO loop-body
148 | * +- UNTIL -+
149 | *
150 | * post-tested-loop --- DO loop-body -+- WHILE -+- test
151 | * +- UNTIL -+
152 | */
153 | class TestedLoopExprAST : public LoopExprAST
154 | {
155 | };
156 |
157 | /*
158 | * exit-expression -+- leave-expression
159 | * +- exit-loop-expression
160 | *
161 | * leave-expression --- LEAVE label -+- WITH exit-value
162 | * +- nothing
163 | *
164 | * exit-loop-expression --- EXITLOOP -+- exit-value
165 | * +- nothing
166 | *
167 | * exit-value --- expression
168 | */
169 | class ExitExprAST : public ControlExprAST
170 | {
171 | };
172 |
173 | /*
174 | * return-expression --- RETURN -+- returned-value
175 | * +- nothing
176 | *
177 | * returned-value --- expression
178 | */
179 | class ReturnExprAST : public ControlExprAST
180 | {
181 | };
182 | }
183 |
184 | #endif /* LLVM_BLISS_CONTROLAST_H */
185 |
--------------------------------------------------------------------------------
/include/bliss/AST/DataAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: DataAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 22, 2019, 11:56 AM
23 | */
24 |
25 | #ifndef LLVM_BLISS_DATAAST_H
26 | #define LLVM_BLISS_DATAAST_H
27 |
28 | #include "AST/DeclarationAST.h"
29 | #include "AST/AttributeAST.h"
30 |
31 | using namespace std;
32 |
33 | namespace bliss
34 | {
35 |
36 | /*
37 | * +- own-declaration
38 | * | global-declaration
39 | * | forward-declaration
40 | * data-declaration -+ external-declaration
41 | * | local-declaration
42 | * | stack-local-declaration
43 | * | register-declaration
44 | * +- map-declaration
45 | */
46 | class DataDeclarationAST : public DeclarationAST
47 | {
48 | };
49 |
50 | /*
51 | * own-declaration --- OWN own-item, ... ;
52 | *
53 | * own-item --- own-name -+- : own-attribute...
54 | * +- nothing
55 | *
56 | * own-name --- name
57 | *
58 | * +- allocation-unit
59 | * | extension-attribute
60 | * | structure-attribute
61 | * | field-attribute
62 | * own-attribute -+ alignment-attribute
63 | * | initial-attribute
64 | * | preset-attribute
65 | * | psect-allocation
66 | * +- volatile-attribute
67 | */
68 | class OwnDeclarationAST : public DataDeclarationAST
69 | {
70 | };
71 |
72 | /*
73 | * global-declaration --- GLOBAL global-item, ... ;
74 | *
75 | * global-item --- global-name -+- : global-attribute...
76 | * +- nothing
77 | *
78 | * global-name --- name
79 | *
80 | * +- allocation-unit
81 | * | extension-attribute
82 | * | structure-attribute
83 | * | field-attribute
84 | * global-attribute-+ alignment-attribute
85 | * | initial-attribute
86 | * | preset-attribute
87 | * | psect-attribute
88 | * | volatile-attribute
89 | * +- weak-attribute
90 | */
91 | class GlobalDeclarationAST : public DataDeclarationAST
92 | {
93 | };
94 |
95 | /*
96 | * forward-declaration --- FORWARD forward-item, ... ;
97 | *
98 | * forward-item --- forward-name -+- : forward-attribute
99 | * +- nothing
100 | *
101 | * forward-name --- name
102 | *
103 | * +- allocation-unit
104 | * | extension-attribute
105 | * | structure-attribute
106 | * forward-attribute -+ field-attribute
107 | * | psect-attribute
108 | * | volatile-attribute
109 | * +- addressing-mode-attribute
110 | */
111 | class ForwardDeclarationAST : public DataDeclarationAST
112 | {
113 | };
114 |
115 | /*
116 | * external-declaration --- EXTERNAL external-item, ... ;
117 | *
118 | * external-item --- external-name -+- : external-attribute
119 | * +- nothing
120 | *
121 | * external-name --- name
122 | *
123 | * +- allocation-unit
124 | * | extension-attribute
125 | * | structure-attribute
126 | * external-attribute -+ field-attribute
127 | * | psect-attribute
128 | * | volatile-attribute
129 | * | addressing-mode-attribute
130 | * +- weak-attribute
131 | */
132 | class ExternalDeclarationAST : public DataDeclarationAST
133 | {
134 | };
135 |
136 | /*
137 | * local-declaration --- LOCAL local-item, ... ;
138 | * stack-local-declaration --- STACKLOCAL local-item, ... ;
139 | *
140 | * local-item --- local-name -+- : local-attribute...
141 | * +- nothing
142 | *
143 | * local-name --- name
144 | *
145 | * +- allocation-unit
146 | * | extension-attribute
147 | * | structure-attribute
148 | * local-attribute -+ field-attribute
149 | * | alignment-attribute
150 | * | initial-attribute
151 | * | preset-attribute
152 | * +- volatile-attribute
153 | */
154 | class LocalDeclarationAST : public DataDeclarationAST
155 | {
156 | private:
157 | bool stack_local;
158 | };
159 |
160 | /*
161 | * register-declaration --- REGISTER register-item, ... ;
162 | * external-register-declaration --- EXERNAL REGISTER register-item, ... ;
163 | *
164 | * register-item --- register-name -+- = register-number -+--+- : register-attribute
165 | * +- nothing -----------+ +- nothing
166 | *
167 | * register-name --- name
168 | *
169 | * register-number --- compile-time-constant-expression
170 | *
171 | * +- allocation-unit
172 | * | extension-attribute
173 | * register-attribute -+ structure-attribute
174 | * | field-attribute
175 | * | initial-attribute
176 | * +- preset-attribute
177 | */
178 | class RegisterDeclarationAST : public DataDeclarationAST
179 | {
180 | private:
181 | bool external;
182 | };
183 |
184 | /*
185 | * global-register-declaration --- GLOBAL REGISTER register-item, ... ;
186 | *
187 | * register-item --- register-name --- = register-number --+- : register-attribute
188 | * +- nothing
189 | */
190 | class GlobalRegisterDeclarationAST : public RegisterDeclarationAST
191 | {
192 | };
193 |
194 | /*
195 | * map-declaration --- MAP map-item, ... ;
196 | *
197 | * map-item --- map-name : map-attribute
198 | *
199 | * map-name --- name
200 | *
201 | * +- allocation-unit
202 | * | extension-attribute
203 | * map-attribute -+ structure-attribute
204 | * | field-attribute
205 | * +- volatile-attribute
206 | */
207 | class MapDeclarationAST : public DataDeclarationAST
208 | {
209 | };
210 | }
211 |
212 | #endif /* LLVM_BLISS_DATAAST_H */
213 |
--------------------------------------------------------------------------------
/include/bliss/AST/DeclarationAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: DeclarationAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 22, 2019, 10:31 AM
23 | */
24 |
25 | #ifndef LLVM_BLISS_DECLARATIONAST_H
26 | #define LLVM_BLISS_DECLARATIONAST_H
27 |
28 | #include "AST/AttributeAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * +- data-declaration
37 | * | structure-declaration
38 | * | field-declaration
39 | * | routine-declaration
40 | * | linkage-declaration
41 | * | enable-declaration
42 | * | bound-declaration
43 | * declaration -+ compile-time-declaration
44 | * | macro-declaration
45 | * | require-declaration
46 | * | library-declaration
47 | * | psect-declaration
48 | * | switches-declaration
49 | * | label-declaration
50 | * | builtin-declaration
51 | * +- undeclare-declaration
52 | */
53 | class DeclarationAST : public BaseAST
54 | {
55 | };
56 |
57 | }
58 |
59 | #endif /* LLVM_BLISS_DECLARATIONAST_H */
60 |
--------------------------------------------------------------------------------
/include/bliss/AST/ExecutableFuncAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: OperatorAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 14, 2019, 5:28 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_EXECUTABLEFUNCAST_H
26 | #define LLVM_BLISS_EXECUTABLEFUNCAST_H
27 |
28 | #include "AST/ExprAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * executable-function --- executable-function-name ( -+- actual-parameter, ... -+- )
37 | * +- nothing ---------------+
38 | *
39 | * executable-function-name -+- name
40 | * +- % name
41 | *
42 | * actual-parameter --- expression
43 | */
44 | class ExecutableFuncAST : public ExprAST
45 | {
46 | public:
47 | ExecutableFuncAST(void *Val) : Val(Val) {}
48 |
49 | private:
50 | void *Val;
51 | };
52 | }
53 |
54 |
55 | #endif /* LLVM_BLISS_EXECUTABLEFUNCAST_H */
56 |
--------------------------------------------------------------------------------
/include/bliss/AST/ExprAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: ExprAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 14, 2019, 2:42 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_EXPRAST_H
26 | #define LLVM_BLISS_EXPRAST_H
27 |
28 | #include "AST/BaseAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * ExprAST - Base class for all expression nodes.
37 | *
38 | * +- primary
39 | * expression -+ operator-expression
40 | * | executable-function
41 | * +- control-expression
42 | */
43 | class ExprAST : public BaseAST
44 | {
45 | };
46 | }
47 |
48 | #endif /* LLVM_BLISS_EXPRAST_H */
49 |
--------------------------------------------------------------------------------
/include/bliss/AST/IncludeAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: IncludeAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 28, 2019, 5:10 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_INCLUDEAST_H
26 | #define LLVM_BLISS_INCLUDEAST_H
27 |
28 | #include "AST/BaseAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * require-declaration --- REQUIRE file-designator ;
37 | *
38 | * file-designator --- quoted-string
39 | */
40 | class RequireAST
41 | {
42 | };
43 |
44 | /*
45 | * library-declaration --- LIBRARY file-designator ;
46 | */
47 | class LibraryAST
48 | {
49 | };
50 | }
51 |
52 | #endif /* LLVM_BLISS_INCLUDEAST_H */
53 |
--------------------------------------------------------------------------------
/include/bliss/AST/LexicalAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: LexicalAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 28, 2019, 4:09 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_LEXICALAST_H
26 | #define LLVM_BLISS_LEXICALAST_H
27 |
28 | #include "AST/ExprAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * lexical-expression -+- primitive
37 | * +- non-primitive
38 | */
39 | class LexicalExprAST : public ExprAST
40 | {
41 | };
42 |
43 | /*
44 | * +- delimiter
45 | * | keyword
46 | * primitive -+ name
47 | * | numeric-literal
48 | * +- string-literal
49 | */
50 | class PrimitiveLexicalAST : public LexicalExprAST
51 | {
52 | };
53 |
54 | /* +- lexical-function
55 | * | lexical-conditional
56 | * non-primitive -+ macro-call
57 | * | require-declaration
58 | * +- library-declaration
59 | *
60 | * +- ( lexical-actual-parameter, ... )
61 | * lexical-function --- lexical-function-name -+ lexeme
62 | * +- nothing
63 | *
64 | * lexical-function-name --- % name
65 | *
66 | * lexical-actual-parameter -+- lexeme...
67 | * +- nothing
68 | *
69 | * Specific Lexical-Functions
70 | *
71 | * String-Functions: %STRING %EXACTSTRING %CHAR %CHARCOUNT
72 | * Delimiter-Functions: %EXPLODE %REMOVE
73 | * Name-Functions: %NAME %QUOTENAME
74 | * Sequence-Test-Functions: %NULL %IDENTICAL
75 | * Expression-Test-Functions: %ISSTRING %CTCE %LTCE
76 | * Bits-Functions: %NBITSU %NBITS
77 | * Allocation-Functions: %ALLOCATION %SIZE
78 | * FieldExpand-Function: %FIELDEXPAND
79 | * Calculation-Functions %ASSIGN %NUMBER
80 | * Compiler-State-Functions: %DECLARED %SWITCHES %BLISS %VARIANT
81 | * Advisory-Functions: %ERROR %WARN %INFORM %PRINT %MESSAGE %ERRORMACRO
82 | * Titling-Functions: %TITLE %SBTTL
83 | * Quote-Functions: %QUOTE %UNQUOTE %EXPAND
84 | * Macro-Functions: %REMAINING %LENGTH %COUNT %EXITITERATION %EXITMACRO
85 | * Require-Function: %REQUIRE
86 | */
87 | class LexicalFunctionAST : public LexicalExprAST
88 | {
89 | };
90 |
91 | /*
92 | * lexical-conditional --- %IF lexical-test %THEN lexical-consequence -+- %ELSE lexical-alternative -+- %FI
93 | * +- nothing -------------------+
94 | *
95 | * lexical-test --- compile-time-constant-expression
96 | *
97 | * lexical-consequence -+--+- lexeme...
98 | * lexical-alternative -+ +- nothing
99 | */
100 | class LexicalConditionalAST : public LexicalExprAST
101 | {
102 | };
103 | }
104 |
105 | #endif /* LLVM_BLISS_LEXICALAST_H */
106 |
--------------------------------------------------------------------------------
/include/bliss/AST/LinkageAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: LinkageAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 28, 2019, 11:40 AM
23 | */
24 |
25 | #ifndef LLVM_BLISS_LINKAGEAST_H
26 | #define LLVM_BLISS_LINKAGEAST_H
27 |
28 | #include "AST/DeclarationAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * linkage-declaration --- LINKAGE linkage-definition, ...;
37 | *
38 | * linkage-definition --- linkage-name = linkage-type --
39 | * -- ( -+- input-parameter-location, ... -+--+- ; output-parameter-location, ... ) -+--+- : linkage-option, ...
40 | * +- nothing -----------------------+ +- nothing ----------------------------+ +- nothing
41 | *
42 | * +- CALL
43 | * linkage-type -+ JSB
44 | * +- INTERRUPT
45 | *
46 | * +- REGISTER = register-number
47 | * input-parameter-location -+ STANDARD
48 | * +- nothing
49 | *
50 | * output-parameter-location --- REGISTER = register-number
51 | *
52 | * +- GLOBAL ( global-register-segment, ...)
53 | * linkage-option -+ +- PRESERVE ---+
54 | * +--+ NOPRESERVE -+- ( register-number, ... )
55 | * +- NOTUSED ----+
56 | *
57 | * global-register-segment --- global-register-name = register-number
58 | *
59 | * global-register-name -+- name
60 | * linkage-name ---------+
61 | *
62 | * register-number --- compile-time-constant-expression
63 | */
64 | class LinkageDeclAST : public DeclarationAST
65 | {
66 | };
67 |
68 | /*
69 | * Predeclared linkage functions:
70 | * ACTUALCOUNT()
71 | * Restriction: Must be declared BUILTIN within the body of a routine whose linkage-attribute is defined with certain
72 | * linkage-types.
73 | * Value: Return the number of actual-parameters passed to the routine using STANDARD parameter-locations. Parameters
74 | * pass using REGISTER parameter-locations are not included in the returned value.
75 | * ACTUALPATAMETER(ii)
76 | * Restriction: The first restriction for ACTUALPARAMGER is the same as ACTUALCOUNT. The value of ii must be in the
77 | * range of 1 to ACTUALCOUNT().
78 | * Value: Return the value of the ii-th actual-parameter that was passed using STANDARD parameter-locations; parameters
79 | * passed using REGISTER parameter-locations are not obtainable with this function.
80 | * ARGPTR()
81 | * Restriction: The restriction for ARGPTR is the same as for ACTUALCOUNT.
82 | * Value: Return the address of the argument block.
83 | *
84 | * NULLPARAMETER(ii)
85 | * Restriction: If ii is not a formal-name, then it is interpreted as an expression and the value of ii must then be
86 | * greater than or equal to 1.
87 | * Value: Returns true if the value of the ii-th actual-parameter was null or omitted.
88 | */
89 | }
90 |
91 | #endif /* LLVM_BLISS_LINKAGEAST_H */
92 |
--------------------------------------------------------------------------------
/include/bliss/AST/MacroAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: MacroAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 28, 2019, 4:41 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_MACROAST_H
26 | #define LLVM_BLISS_MACROAST_H
27 |
28 | #include "AST/DeclarationAST.h"
29 | #include "AST/ExprAST.h"
30 |
31 | using namespace std;
32 |
33 | namespace bliss
34 | {
35 |
36 | /*
37 | * macro-declaration -+- positional-macro-declaration
38 | * +- keyword-macro-declaration
39 | *
40 | * Pre-declared Macros
41 | * Name 32-bit 64-bit
42 | * %BLISS32[] = %REMAINING %; %;
43 | * %BLISS64[] = %; %REMAINING %;
44 | */
45 | class MacroDeclAST : public DeclarationAST
46 | {
47 | };
48 |
49 | /*
50 | * positional-macro-declaration --- MACRO positional-macro-definition, ...;
51 | *
52 | * +- simple-macro-definition
53 | * positional-macro-definition -+ conditional-macro-definition
54 | * +- iterative-macro-definition
55 | *
56 | * simple-macro-definition --- macro-name -+- ( macro-formal-name, ... ) -+- macro-body %
57 | * +- nothing --------------------+
58 | *
59 | * conditional-macro-definition --- macro-name -+- ( macro-formal-name, ... ) -+- [] = macro-body %
60 | * +- nothing --------------------+
61 | *
62 | * iterative-macro-definition --- macro-name -+- ( fixed-formal-name, ... ) -+- [ iterative-formal-name, ... ] = macro-body %
63 | * +- nothing --------------------+
64 | *
65 | * macro-name ---=----+
66 | * macro-formal-name +- name
67 | * fixed-formal-name -+
68 | *
69 | * macro-body -+- lexeme...
70 | * +- nothing
71 | */
72 | class PositionalMacroDeclAST : public MacroDeclAST
73 | {
74 | };
75 |
76 | /*
77 | * keyword-macro-declaration --- KEYWORDMACRO keyword-macro-definition, ... ;
78 | *
79 | * keyword-macro-definition --- macro-name ( keyword-pair, ... ) = macro-body %
80 | *
81 | * keyword-pair --- keyword-formal-name -+- = default-actual
82 | * +- nothing
83 | *
84 | * keyword-formal-name --- name
85 | *
86 | * default-actual -+- lexeme...
87 | * +- nothing
88 | */
89 | class KeywordMacroDeclAST : public MacroDeclAST
90 | {
91 | };
92 |
93 | /*
94 | * macro-call -+- positional-macro-call
95 | * +- keyword-macro-call
96 | */
97 | class MacroCallAST : public ExprAST
98 | {
99 | };
100 |
101 | /* +- ( macro-actuals )
102 | * positional-macro-call --- macro-name -+ [ macro-actuals ]
103 | * | < macro-actuals >
104 | * +- nothing
105 | *
106 | * macro-actuals -+- macro-actual-parameter, ...
107 | * +- nothing
108 | *
109 | * macro-actual-parameter -+- lexeme ...
110 | * +- nothing
111 | */
112 | class PositionalMacroCallAST : public MacroCallAST
113 | {
114 | };
115 |
116 | /* +- ( keyword-assignments )
117 | * keyword-macro-call --- macro-name -+ [ keyword-assignments ]
118 | * + < keyword-assignments >
119 | *
120 | * keyword-assignments -+- keyword-assignment, ...
121 | * +- nothing
122 | *
123 | * keyword-assignment --- keyword-formal-name = macro-actual-parameter
124 | */
125 | class KeywordMacroCallAST : public MacroCallAST
126 | {
127 | };
128 | }
129 |
130 | #endif /* LLVM_BLISS_MACROAST_H */
131 |
--------------------------------------------------------------------------------
/include/bliss/AST/ModuleAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: ModuleAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 28, 2019, 5:54 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_MODULEAST_H
26 | #define LLVM_BLISS_MODULEAST_H
27 |
28 | #include "AST/SpecialAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * module --- MODULE module-head = module-body ELUDOM
37 | *
38 | * module-head --- module-name -+- ( module-switch, ... )
39 | * +- nothing
40 | *
41 | * module-name --- name
42 | *
43 | * module-body --- block
44 | *
45 | * module-switch -+- on-off-switch
46 | * +- special-switch
47 | *
48 | * +- CODE | NOCODE
49 | * | DEBUG | NODEBUG
50 | * | ERRS | NOERRS
51 | * on-off-switch -+ OPTIMIZE | NOOPTIMIZE
52 | * | SAFE | NOSAFE
53 | * | UNAMES | NOUNAMES
54 | * +- ZIP | NOZIP
55 | *
56 | * +- common-switch
57 | * special-switch -+ bliss-32-switch
58 | * +- bliss-64-switch
59 | *
60 | * +- IDENT = quoted-string
61 | * | LANGUAGE ( language-list, ... )
62 | * | LINKAGE ( linkage-name)
63 | * common-switch -+ LIST ( list-options )
64 | * | STRUCTURE -+- ( structure-attribute )
65 | * | +- nothing
66 | * | MAIN = routine-name
67 | * | OPTLEVEL = 0 | 1 | 2 | 3
68 | * +- VERSION = quoted-string
69 | *
70 | */
71 | class ModuleAST : public BaseAST
72 | {
73 | public:
74 | ModuleAST(const string &Name) : Name(Name) {}
75 |
76 | private:
77 | string Name;
78 | SwitchesDeclAST switches;
79 | };
80 | }
81 |
82 | #endif /* LLVM_BLISS_MODULEAST_H */
83 |
--------------------------------------------------------------------------------
/include/bliss/AST/OperatorAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: OperatorAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 14, 2019, 5:28 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_OPERATORAST_H
26 | #define LLVM_BLISS_OPERATORAST_H
27 |
28 | #include "AST/ExprAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * Every operator has one of the following forms:
37 | *
38 | * prefix-operator rhs
39 | * lhs infix-operator rhs
40 | *
41 | * Direction of
42 | * Association
43 | * ------------
44 | * +- . rhs <---
45 | * |
46 | * | + -+- rhs <---
47 | * | - -+
48 | * |
49 | * | lhs ^ rhs --->
50 | * |
51 | * | +- MOD -+
52 | * | lhs -+ * +- rhs --->
53 | * | +- / ---+
54 | * |
55 | * operator-expression -+ lhs -+- + -+- rhs --->
56 | * | +- - -+
57 | * |
58 | * | +- EQL[ UA] -+
59 | * | | NEQ[ UA] |
60 | * | lhs -+ LSS[ UA] +- rhs --->
61 | * | | LEQ[ UA] |
62 | * | | GTR[ UA] |
63 | * | +- GEQ[ UA] -+
64 | * |
65 | * | NOT rhs <---
66 | * |
67 | * | lhs AND rhs --->
68 | * |
69 | * | lhs OR rhs --->
70 | * |
71 | * | lhs -+- EQV -+- rhs --->
72 | * | +- XOR -+
73 | * |
74 | * +- lhs = rhs <---
75 | *
76 | * +- primary
77 | * lhs -+-+ operator-expression
78 | * rhs -+ +- executable-function
79 | */
80 | class OperatorExprAST : public ExprAST
81 | {
82 | public:
83 | OperatorExprAST(void *Val) : Val(Val) {}
84 |
85 | private:
86 | void *Val;
87 | };
88 | }
89 |
90 | #endif /* LLVM_BLISS_OPERATORAST_H */
91 |
--------------------------------------------------------------------------------
/include/bliss/AST/PrimaryAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: PrimaryAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 14, 2019, 4:42 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_PRIMARYAST_H
26 | #define LLVM_BLISS_PRIMARYAST_H
27 |
28 | #include "AST/ExprAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * +- numeric-literal
37 | * | string-literal
38 | * | plit
39 | * | name
40 | * primary -+ block
41 | * | structure-reference
42 | * | routine-call
43 | * | field-reference
44 | * +- code-comment
45 | */
46 | class PrimaryExprAST : public ExprAST
47 | {
48 | public:
49 | virtual ~PrimaryExprAST() {}
50 | };
51 |
52 | /*
53 | * +- decimal-literal
54 | * numeric-literal -+ integer-literal
55 | * | character-code-literal
56 | * +- float-literal
57 | *
58 | * decimal-literal --- decimal-digit...
59 | *
60 | * decimal-digit --- 0..9
61 | *
62 | * +- %B -------+
63 | * integer-literal -+ %O +- ' opt-sign integer-digit... '
64 | * | %DECIMAL |
65 | * +- %X -------+
66 | *
67 | * +- + (positive)
68 | * opt-sign -+ - (negative)
69 | * +- nothing (positive)
70 | *
71 | * integer-digit --- 0..9 A..F
72 | *
73 | * character-coded-literal - %C ' quoted-character '
74 | *
75 | * +- single-precision-float-literal
76 | * float-literal -+ double-precision-float-literal
77 | * | extended-exponent-double-precision-float-literal
78 | * +- extended-exponent-extended-precision-float-literal
79 | *
80 | * single-precision-float-literal -+- %E -+- ' mantissa -+- E exponent -+- '
81 | * +- %T -+ +- nothing ----+
82 | *
83 | * double-precision-float-literal -+- %D -+- ' mantissa -+- E exponent -+- '
84 | * +- %S -+ +- nothing ----+
85 | *
86 | * extended-exponent-double-precision-float-literal -+- %G -+- ' mantissa -+- Q exponent -+- '
87 | * +- %? -+ +- nothing ----+
88 | *
89 | * extended-exponent-extended-precision-float-literal -- %H ' mantissa -+- Q exponent -+- '
90 | * +- nothing ----+
91 | *
92 | * +- decimal-digits
93 | * mantissa --- opt-sign -+ decimal-digits .
94 | * | . decimal-digits
95 | * +- decimal-digits . decimal-digits
96 | *
97 | * exponent -- opt-sign decimal-digits
98 | */
99 | class NumericLiteral : public PrimaryExprAST
100 | {
101 | public:
102 | NumericLiteral(float TVal) : TVal(TVal) {}
103 | NumericLiteral(double SVal) : SVal(SVal) {}
104 | NumericLiteral(long double XVal) : XVal(XVal) {}
105 | NumericLiteral(uint64_t IVal) : IVal(IVal) {}
106 | NumericLiteral(char CVal) : CVal(CVal) {}
107 |
108 | private:
109 | float TVal;
110 | double SVal;
111 | long double XVal;
112 | uint64_t IVal; // For both decimal- and integer-literals
113 | char CVal;
114 | };
115 |
116 | /*
117 | * string-literal -+- string-type -+- quoted-string
118 | * +- nothing -+
119 | *
120 | * +- %ASCII
121 | * | %ASCIZ
122 | * string-type -+ %ASCIC
123 | * | %ASCID
124 | * +- %P
125 | *
126 | * quoted-string --- ' quoted-character... '
127 | *
128 | * +- printing-character-except-apostrophe
129 | * quoted-character -+ blank
130 | * | tab
131 | * +- '' (escape sequence for an apostrophe)
132 | * printing-character --- ASCII 33 through ASCII 126, inclusive
133 | * blank --- ASCII 32
134 | * tab --- ASCII 9
135 | * apostrophe --- ASCII 39
136 | */
137 | class StringLiteral : public PrimaryExprAST
138 | {
139 | public:
140 | StringLiteral(string Str) : Str(Str) {}
141 | StringLiteral(DSC64_DESCRIPTOR StrDSC) : StrDSC(StrDSC) {}
142 |
143 | private:
144 | string Str;
145 | DSC64_DESCRIPTOR StrDSC;
146 | };
147 |
148 | /*
149 | * +- allocation-unit ---------------- +
150 | * plit -+- PLIT --+-+ psect-allocation +- ( plit-item )
151 | * +- UPLIT -+ | psect-allocation allocation-unit |
152 | * +- nothing -------------------------+
153 | *
154 | * +- QUAD
155 | * | LONG
156 | * allocation-unit -+ WORD
157 | * +- BYTE
158 | *
159 | * psect-allocation --- PSECT ( psect-name )
160 | *
161 | * psec-name --- name
162 | *
163 | * +- plit-group
164 | * plit-item -+ plit-expression
165 | * +- plit-string
166 | *
167 | * +- allocation-unit -------------------+
168 | * plit-group -+ REP replicator OF +- ( plit-item, ... )
169 | * +- REP replicator OF allocation-unit -+
170 | *
171 | * replicator --- compile-time-constant-expression
172 | *
173 | * plit-expression --- link-time-constant-expression
174 | *
175 | * plit-string --- string-literal
176 | */
177 | class Plit : public PrimaryExprAST
178 | {
179 | };
180 |
181 | /*
182 | * +- + letter
183 | * +- letter -----+ | | digit
184 | * name -+ dollar +-+ -+ dollar
185 | * +- underscore -+ | + underscore
186 | * +- nothing
187 | *
188 | * letter --- A..Z a..Z
189 | *
190 | * digit --- 0..9
191 | *
192 | * dollar --- $
193 | *
194 | * underscore --- _
195 | */
196 | class Name : public PrimaryExprAST
197 | {
198 | public:
199 | Name(string Str) : Str(Str) {}
200 |
201 | private:
202 | string Str;
203 | };
204 |
205 | /*
206 | * block -+- labeled-block
207 | * +- unlabeled-block
208 | *
209 | * labeled-block --- {label:}... unlabeled-block
210 | *
211 | * label --- name
212 | *
213 | * unlabeled-block -+- BEGIN block-body END
214 | * +- ( block-body )
215 | *
216 | * +-+- declaration ...
217 | * | +- nothing
218 | * |
219 | * block-body -+-+- block-action ...
220 | * | +- nothing
221 | * |
222 | * +-+- block-value
223 | * +- nothing
224 | *
225 | * block-action --- expression ;
226 | *
227 | * block-value --- expression
228 | */
229 | class Block : public PrimaryExprAST
230 | {
231 | };
232 |
233 | /*
234 | * +- ordinary-structure-reference
235 | * structure-reference -+ default-structure-reference
236 | * +- general-structure-reference
237 | *
238 | * ordinary-structure-reference --- segment-name [ access-actual, ... ]
239 | *
240 | * segment-name --- name
241 | *
242 | * +- field-name
243 | * access-actual -+ expression
244 | * +- nothing
245 | *
246 | * default-structure-reference --- address [ access-actual, ... ]
247 | *
248 | * address -+- primary
249 | * +- executable-function
250 | *
251 | * general-structure-reference --- structure-name [ access-part -+- ; allocation-actual, ... -+- ]
252 | * +- nothing ------------------+
253 | *
254 | * access-part --- segment-expression -+- , access-actual
255 | * +- nothing
256 | *
257 | * segment-expression -+- expression
258 | * +- nothing
259 | */
260 | class Structure : public PrimaryExprAST
261 | {
262 | };
263 |
264 | /*
265 | * routine-call -+- ordinary-routine-call
266 | * +- general-routine-call
267 | */
268 | class RoutineAST : public PrimaryExprAST
269 | {
270 | };
271 |
272 | /*
273 | * ordinary-routine-call --- routine-designator ( -+- input-actual-parameter, ... -+--+- ; output-actual-parameter, ... -+- )
274 | * +- nothing ---------------------+ +- nothing ------------------------+
275 | *
276 | * routine-designator --- primary
277 | *
278 | * input-actual-parameter -+- expression
279 | * +- nothing
280 | *
281 | * output-actual-parameter -+- expression
282 | * +- nothing
283 | */
284 | class OrdinaryRoutineAST : public RoutineAST
285 | {
286 | };
287 |
288 | /*
289 | * general-routine-call --- linkage-name ( routine-address --
290 | * -+- , input-actual-parameter, ... -+--+- ; output-actual-parameter, ... -+- )
291 | * +- nothing -----------------------+ +- nothing ------------------------+
292 | *
293 | * routine-address --- expression
294 | */
295 | class GeneralRoutineAST : public RoutineAST
296 | {
297 | };
298 |
299 | /*
300 | * field-reference --- address -+- field-selector
301 | * +- nothing
302 | *
303 | * field-selector --- < position, size -+- , sign-extension-flag -+- >
304 | * +- nothing ---------------+
305 | *
306 | * position -+- expression
307 | * size -----+
308 | *
309 | * sing-extension-flag --- compile-time-constant-expression
310 | */
311 | class Field : public PrimaryExprAST
312 | {
313 | };
314 |
315 | /*
316 | * code-comment --- CODECOMMENT quoted-string,... : block
317 | */
318 | class CodeComment : public PrimaryExprAST
319 | {
320 | public:
321 | CodeComment(string Str) : Str(Str) {}
322 |
323 | private:
324 | string Str;
325 | };
326 | }
327 |
328 | #endif /* LLVM_BLISS_PRIMARYAST_H */
329 |
--------------------------------------------------------------------------------
/include/bliss/AST/RoutineAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: RoutineAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 28, 2019, 8:19 AM
23 | */
24 |
25 | #ifndef LLVM_BLISS_ROUTINEAST_H
26 | #define LLVM_BLISS_ROUTINEAST_H
27 |
28 | #include "AST/DeclarationAST.h"
29 | #include "AST/ExprAST.h"
30 |
31 | using namespace std;
32 |
33 | namespace bliss
34 | {
35 |
36 | /*
37 | * +- ordinary-routine-declaration
38 | * routine-declaration -+ global-routine-declaration
39 | * | forward-routine-declaration
40 | * +- external-routine-declaration
41 | *
42 | * ordinary-routine-declaration --- nothing -+- ROUTINE routine-definition, ...;
43 | * global-routine-declaration --- GLOBAL ----+
44 | *
45 | * +- ( input-list ) ------------- -+
46 | * routine-definition --- routine-name -+ ( ; output-list ) +--+- : routine-attribute... -+- = routine-body
47 | * | ( input-list ; output-list ) | +- nothing ----------------+
48 | * +- nothing ----------------------+
49 | *
50 | * routine-name --- name
51 | *
52 | * input-list --- input-formal-parameter, ...
53 | *
54 | * output-list --- output-formal-parameter, ...
55 | *
56 | * input-formal-parameter --+- formal-item
57 | * output-formal-parameter -+
58 | *
59 | * formal-item --- formal-name -+- : formal-attribute-list
60 | * +- nothing
61 | *
62 | * formal-name --- name
63 | *
64 | * formal-attribute-list --- map-declaration-attribute ...
65 | *
66 | * +- allocation-unit
67 | * | extension-attribute
68 | * map-declaration-attribute -+ structure-attribute
69 | * | field-attribute
70 | * +- volatile-attribute
71 | *
72 | * +- novalue-attribute
73 | * | linkage-attribute
74 | * routine-attribute -+ psect-allocation
75 | * | addressing-mode-attribute
76 | * +- weak-attribute
77 | *
78 | * routine-body --- expression
79 | */
80 | class RoutineDeclAST : public DeclarationAST
81 | {
82 | public:
83 | RoutineDeclAST(bool globalDeclaration = false);
84 |
85 | private:
86 | bool global;
87 | };
88 |
89 | /*
90 | * forward-routine-declaration --- FORWARD ROUTINE forward-routine-item, ...;
91 | *
92 | * forward-routine-item --- routine-name -+- : fwd-routine-attribute ...
93 | * +- nothing
94 | *
95 | * +- novalue-attribute
96 | * fwd-routine-attribute -+ linkage-attribute
97 | * | psect-allocation
98 | * +- addressing-mode-attribute
99 | *
100 | * routine-name --- name
101 | */
102 | class FwdRoutineDeclAST : public DeclarationAST
103 | {
104 | };
105 |
106 | /*
107 | * external-routine-declaration --- EXTERNAL ROUTINE external-routine-item, ...;
108 | *
109 | * external-routine-item --- routine-name -+- : ext-routine-attribute ...
110 | * +- nothing
111 | *
112 | * +- novalue-attribute
113 | * | linkage-attribute
114 | * ext-routine-attribute -+ psect-allocation
115 | * | addressing-mode-attribute
116 | * +- weak-attribute
117 | *
118 | * routine-name --- name
119 | */
120 | class ExtRoutineDeclAST : public DeclarationAST
121 | {
122 | };
123 | }
124 |
125 | #endif /* LLVM_BLISS_ROUTINEAST_H */
126 |
--------------------------------------------------------------------------------
/include/bliss/AST/SpecialAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: SpecialAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 28, 2019, 5:46 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_SPECIALAST_H
26 | #define LLVM_BLISS_SPECIALAST_H
27 |
28 | #include "AST/DeclarationAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * psect-declaration --- PSECT psect-item, ... ;
37 | *
38 | * psect-item --- storage-class = psect-name -+- ( psect-attribute, ... )
39 | * +- nothing
40 | *
41 | * +- OWN
42 | * | GLOBAL
43 | * storage-class -+ PLIT
44 | * | CODE
45 | * +- NODEFAULT
46 | *
47 | * psect-name --- name
48 | *
49 | * +- WRITE | NOWRITE
50 | * | EXECUTE | NOEXECUTE
51 | * | OVERLAY | NOOVERLAY
52 | * | READ | NOREAD
53 | * psect-attribute -+ SHARE | NOSHARE
54 | * | PIC | NOPIC
55 | * | LOCAL | GLOBAL
56 | * | VECTOR
57 | * | alignment-attribute
58 | * +- addressing-mode-attribute
59 | */
60 | class PsectDeclAST : public DeclarationAST
61 | {
62 | };
63 |
64 | /*
65 | * switches-declaration --- SWITCHES switch-item, ... ;
66 | *
67 | * switch-item -+- on-off-switch-item
68 | * +- special-switch-item
69 | *
70 | * +- ERRS | NOERRS
71 | * | OPTIMIZE | NOOPTIMIZE
72 | * on-off-switch-item -+ SAFE | NOSAFE
73 | * | UNAMES | NOUNAMES
74 | * +- ZIP | NOZIP
75 | *
76 | * +- ADDRESSING_MODE ( mode-spec, ... )
77 | * | LANGUAGE ( language-list )
78 | * special-switch-item -+ LINKAGE ( linkage-name )
79 | * | LIST ( list-option, ... )
80 | * +- STRUCTURE -+- ( structure-attribute )
81 | * +- nothing
82 | *
83 | * +- COMMON
84 | * language-list -+ language-name
85 | * +- nothing
86 | *
87 | * language-name -+- BLISS32
88 | * +- BLISS64
89 | *
90 | * linkage-name --- name
91 | *
92 | * +- SOURCE | NOSOURCE
93 | * | REQUIRE | NOREQUIRE
94 | * | EXPAND | NOEXPAND
95 | * | TRACE | NOTRACE
96 | * list-option -+ LIBRARY | NOLIBRARY
97 | * | OBJECT | NOOBJECT
98 | * | ASSEMBLY | NOASSEMBLY
99 | * | SYMBOLIC | NOSYMBOLIC
100 | * | BINARY | NOBINARY
101 | * +- COMMENTARY | NOCOMMENTARY
102 | *
103 | * mode-spec -+- EXTERNAL ----+-- mode
104 | * +- NONEXTERNAL -+
105 | *
106 | * +- GENERAL
107 | * mode -+ ABSOLUTE
108 | * | LONG_RELATIVE
109 | * +- WORD_RELATIVE
110 | */
111 | class SwitchesDeclAST : public DeclarationAST
112 | {
113 | };
114 |
115 | /*
116 | * built-in-declaration --- BUILTIN built-in-name, ... ;
117 | *
118 | * built-in-name --- name
119 | */
120 | class BuiltInAST : public DeclarationAST
121 | {
122 | };
123 |
124 | /*
125 | * label-declaration --- LABEL label-name, ... ;
126 | *
127 | * label-name --- name
128 | */
129 | class LabelAST : public DeclarationAST
130 | {
131 | };
132 |
133 | /*
134 | * undeclare-declaration --- UNDECLARE undeclare-name, ... ;
135 | *
136 | * undeclare-name --- name
137 | */
138 | class UndeclareAST : public DeclarationAST
139 | {
140 | };
141 | }
142 |
143 | #endif /* LLVM_BLISS_SPECIALINAST_H */
144 |
--------------------------------------------------------------------------------
/include/bliss/AST/StructureAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: StructureAST.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on September 22, 2019, 1:02 PM
23 | */
24 |
25 | #ifndef LLVM_BLISS_STRUCTUREAST_H
26 | #define LLVM_BLISS_STRUCTUREAST_H
27 |
28 | #include "AST/DeclarationAST.h"
29 |
30 | using namespace std;
31 |
32 | namespace bliss
33 | {
34 |
35 | /*
36 | * field-reference --- address -+- field-selector
37 | * +- nothing
38 | *
39 | * address -+- primary
40 | * +- executable-function
41 | *
42 | * field-selector --- < position , size -+- , sign-extension-flag -+- >
43 | * +- nothing ---------------+
44 | *
45 | * position -+- expression
46 | * size -----+
47 | *
48 | * sign-extension-flag --- compile-time-constant-expression
49 | */
50 | class FieldReferenceAST : public DeclarationAST
51 | {
52 | };
53 |
54 | /*
55 | * structure-declaration --- STRUCTURE structure-definition, ... ;
56 | *
57 | * structure-definition -- structure-name [ -+- access-formal -+--+- : allocation-formal -+- ] =
58 | * +- nothing -------+ +- nothing -------------+
59 | *
60 | * -+- [ structure-size ] -+- structure-body
61 | * +- nothing ------------+
62 | *
63 | * allocation-formal --- allocation-name -+- = allocation default
64 | * +- nothing
65 | *
66 | * structure-size -+- expression
67 | * structure-body -+
68 | *
69 | * structure-name --+
70 | * access-formal +- name
71 | * allocation-name -+
72 | *
73 | * allocation-default -- compile-time-constant-expression
74 | */
75 | class StructureDeclarationAST : public DeclarationAST
76 | {
77 | };
78 |
79 | /*
80 | * field-declaration --- FIELD -+- field-set-definition -+- , ... ;
81 | * +- field-definition -----+
82 | *
83 | * field-set-definition --- field-set-name = SET field-definition, ... TES
84 | *
85 | * field-definition --- field-name = [ field-component, ... ]
86 | *
87 | * field-set-name -+- name
88 | * field-name -----+
89 | *
90 | * field-component --- compile-time-constant-expression
91 | */
92 | class FieldDeclarationAST : public DeclarationAST
93 | {
94 | };
95 |
96 | /*
97 | * +- ordinary-structure-reference
98 | * structure-reference -+ default-structure-reference
99 | * +- general-structure-reference
100 | *
101 | * ordinary-structure-reference --- segment-name [ access-actual, ... ]
102 | *
103 | * segment-name --- name
104 | *
105 | * +- field-name
106 | * access-actual -+ expression
107 | * +- nothing
108 | */
109 | class OrdinaryStructReferenceAST : public DeclarationAST
110 | {
111 | };
112 |
113 | /*
114 | * default-structure-reference --- address [ access-actual, ... ]
115 | */
116 | class DefaultStructReferenceAST : public DeclarationAST
117 | {
118 | };
119 |
120 | /*
121 | * general-structure-reference --- structure-name [ access-part -+- : allocation-actual, ... -+- ]
122 | * +- nothing ------------------+
123 | *
124 | * access-part --- segment-expression -+- , access-actual, ...
125 | * +- nothing
126 | *
127 | * segment-expression -+- expression
128 | * +- nothing
129 | */
130 | class GeneralStructReferenceAST : public DeclarationAST
131 | {
132 | };
133 |
134 | /*
135 | * Predeclared Structures
136 | *
137 | * VECTOR - A vector of signed or unsigned elements of uniform size (BYTE, WORD, LONG, or QUAD)
138 | * BITVECTOR - A vector of 1 bit element
139 | * BLOCK - A sequence of varying-sized fields
140 | * BLOCKBYTE - This structure is functionally equivalent to BLOCK[,BYTE]
141 | * BLOCKVECTOR - A vector of BLOCKs
142 | */
143 | class BlockDeclarationAST : public DeclarationAST
144 | {
145 | private:
146 | map<> fields;
147 | };
148 | class VectorDeclarationAST : public DeclarationAST
149 | {
150 | private:
151 | vector<> elements;
152 | uint64_t element_size;
153 | };
154 | class BitVectorDeclarationAST : public DeclarationAST
155 | {
156 | private:
157 | vector<> bits;
158 | uint64_t numberOfBits;
159 | uint64_t size; // in Bytes
160 | };
161 | }
162 |
163 | #endif /* LLVM_BLISS_STRUCTUREAST_H */
164 |
--------------------------------------------------------------------------------
/include/bliss/Basic/CommonInclude.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 Jonathan D. Belanger
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | /*
19 | * File: CommonInclude.h
20 | * Author: Jonathan D. Belanger
21 | *
22 | * Created on August 25, 2019, 9:39 AM
23 | */
24 |
25 | #ifndef LLVM_BLISS_COMMONINCLUDE_H
26 | #define LLVM_BLISS_COMMONINCLUDE_H
27 |
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include