marcofiset / migraine Goto Github PK
View Code? Open in Web Editor NEWA set of projects related to the Brainfuck programming language
A set of projects related to the Brainfuck programming language
Here are the steps required to implement variables :
=
to the list of operatorsA lot of information is no longer relevant and accurate.
Currently, I use the shunting yard algorithm for evaluating expression. This is not a very extensible solution if I want to build a complete programming language. I must now define a grammar and write a recursive descent parser for it so I can add functionnality easily in the grammar and parser. This will be the first step before proceeding to implement the language.
For the moment, input and output for the brainfuck interpreter uses the Console and there is no way to change that. Make it so input source and output destination are dynamic. Use an interface, something along those lines :
public interface IInputOutputProvider
{
string GetInput();
void WriteToOutput(string value);
}
This will require the token class to hold the line and the column at which it was produced by the Lexer.
These projects are separate, but they could be together.
In the ValidateSourceFile
method, we loop through every character in the string and check whether we support it as an action. We should skip whitespaces and line breaks.
There is a potential bug in this condition when jumping to the end of a loop:
} while (loopIndexes.Count > 0);
It should rather be :
} while (loopIndexes.Count > currentLoopCount);
For the moment, we rely on the token definition order for matches. We should instead rely on the longest match.
A scope is delimited by a code block (as defined by the grammar rule)
High code coverage is needed when I want to refactor. Will be easier to favor TDD if everything is covered by tests. Marked as a bug because I want to fix this first.
The check-box and textbox are available to pre-supply input, but they are not supported yet.
In MainViewPresenter, do not delegate to the view to get input. On program execution, the presenter should ask the view for any pre-supplied inputs and store them in a queue. If no more input in the pre-supply list, then you should ask the view to get input.
Delete ExpressionEvaluator the real parser supports the same operations and all the same tests pass
This pattern is used everywhere in the parser :
//Test for the token
if (CurrentToken.Type == TokenType.Number)
{
Double termValue = Convert.ToDouble(CurrentToken.Value);
tokenStream.Consume(); //Consume it
}
It could be simplified as :
//Consume the token if it meets the criteria and return true. False if wrong token.
if (tokenStream.Consume(TokenType.Number))
{
//Use the ConsumedToken function to get back the token we just consumed,
//because CurrentToken will no longer hold the value we want.
Double termValue = Convert.ToDouble(ConsumedToken.Value);
}
This will require to implement a ConsumedToken
function on TokenStream
which will hold the last consumed token.
If we want an exception to be thrown, use the to-be-implemented Expect
method instead.
Give meaningful exceptions messages
Or skip them altogether and test the whole thing (Lexing + Parsing) once it is completed.
At first :
Add and implement the following grammar rules :
FunctionDefinition = "fun", Identifier, "(", ")", Block
Block = "{", ExpressionList, "}"
FunctionCall = Identifier, "(", ")"
IdentifierList = Identifier, { ",", Identifier }
ArgumentList = Expression, { ",", Expression }
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.