robertshepherdcpp / ont Goto Github PK
View Code? Open in Web Editor NEWThe Ont Programming Language.
License: MIT License
The Ont Programming Language.
License: MIT License
Hello! So the ont parser currently does not use unions and this issue is here to change that! If you could think of a suitable implementation for the union great!
The ont parser parses a line of code and then turns it into c++ code. It is a bit like herb sutter's cpp2/cppfront int that it is a different syntax to c++ but eventually it gets parsed into c++. If you aren't familiar with this just have a look around main.cpp
found in the code
section of this repository!
The layout needs to be as follows:
is_keyword
near the top of the main.cpp
header file. By doing if(s == "YOUR_KEYWORD)
, note that your YOUR_KEYWORD
is the keyword that you choose for the union.else if(possible_keyword == "YOUR_KEYWORD")
to the parse member function. And then parse the input.str_
.std::string
for dealing with the strings.push_back
the finished string onto the vector called dotcppfile
which will be how the user will be able to see their input changed into c++ code.main
function using the function parse
and passing in your 'ont' code. You could also even add documentation to the readme section of this repository if you were really going for it!So we will need a keyword here are a few ideas:
collection
bond
together
seal
You could just change the keyword and then keep the rest of the union implementation the same!
If you are confused here is an example, the following should be passed to parse (well something similiar because at the end of the day it is whatever you choose is suitable!):
parse("collection c{int a; char b; float c;};");
Then the generated code should be as follows, this will be in the dotcppfile
vector!
union c {int a, char b, float c};
Here is an example of how else if(possible_keyword == "YOUR_KEYWORD")
might look in the parse member function:
// Other else if's before.
else if(possible_keyword == "YOUR_KEYWORD")
{
// This is so that the outputed string will be correctly indented
std::string FINISHED_STRING{amount_str(indent)}; // notice amount_str(indent) is needed.
// This is where we hold the finished string.
std::string rest = str_.substr(strlen(12, str_.size());
// we are making a substring of the string not including the keyword that we are matching.
// Then we finish parsing, accepting as many types in the *union* as possible. But remember all on one line!
dotcppfile.push_back(FINISHED_STRING);
}
Any help is greatly appreciated. Thankyou in advance! If you have any questions just comment below in this issue!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.