mjarkk / general_programming_language

A temporarly repo for an idea to create a programming language that can be compiled into other languages
MIT License
1 stars 0 forks source link

Implemented single line comments #7

Closed TheOtterlord closed 4 years ago

TheOtterlord commented 4 years ago

I've implemented single line comments into our parser. I decided just to ignore them, as there is no point parsing them through.

running 15 tests
test lib::tests::comments::test_comment_single_line ... ok
test lib::tests::functions::test_function_empty ... ok
test lib::tests::functions::test_function_with_arg ... ok
test lib::tests::functions::test_function_with_args ... ok
test lib::tests::functions::test_function_call_without_args ... ok
test lib::tests::functions::test_function_with_arg_and_result ... ok
test lib::tests::functions::test_function_with_result ... FAILED
test lib::tests::functions::test_function_call_with_args ... FAILED
test lib::tests::functions::test_functions_empty ... ok
test lib::tests::general::test_empty ... ok
test lib::tests::variables::test_variable ... FAILED
test lib::tests::variables::test_variable_global_let ... ok
test lib::tests::variables::test_variable_starts_with_number ... ok
test lib::tests::variables::test_variable_string_with_spaces ... FAILED
test lib::tests::variables::test_variable_strings_with_backslashes ... FAILED

Edit: Added multi-line support now

TheOtterlord commented 4 years ago

Thanks for the help.

I've made the changes 😄

mjarkk commented 4 years ago

I've created a mr to fix the issues i pointed out and some code styling improvements here: https://github.com/TheOtterlord/general_programming_language/pull/1

TheOtterlord commented 4 years ago

Thanks.

I’ve merged your PR.

mjarkk commented 4 years ago

Great thanks for making this!

TheOtterlord commented 4 years ago

No problem.

Just wanted to quickly check something.

I was testing using the example file, and noticed that only the first of two functions were parsed. Once the first function is parsed, the rest seems to be ignored.

Here is my example.gpl code:

fn test() {}

fn main() {}

And this is the response:

   Compiling gpl v0.1.0 (C:\Users\reube\source\repos\gpl)
    Finished dev [unoptimized + debuginfo] target(s) in 1.96s
     Running `target\debug\gpl.exe`
[Function { name: Some("test"), args: [], body: Actions { list: [] } }]

Is this something that has not been implemented yet, or a bug?

mjarkk commented 4 years ago

A bug.
Yesterday late in the evening i successfully added support for global consts :) but after making it i noticed all tests also passed successfully but i'm sure a lot of them should not so maybe we should also add checks for the parsed output like the parsed function name, args, variable names and types, etc..

TheOtterlord commented 4 years ago

Ok.

I will have a look at the current code and see if I can narrow down the bug.

Yeah, we need to add some validation to our tests. I will focus on the bug for now, but will have a go at adding validation.

TheOtterlord commented 4 years ago

I don't yet understand this bit of code, but on line 242 before commit a2b8ea61b335da7ffecb186821693af6cec0c22f there was a while loop that has now been removed. As far as I can see this is the only loop that could be causing the issue.

What do you think?

TheOtterlord commented 4 years ago

Continued in #8