Git Product home page Git Product logo

gosyn's Introduction

gosyn's People

Contributors

chikaku avatar gbouv avatar nu11ptr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gosyn's Issues

Add MIT license file

I see in Cargo.toml it is MIT licensed but there is no LICENSE file in the repo

Parsing an invalid string panics, it should return an error

Repro steps:

fn main() {
    let source = "# hello world";

    parse_source(source);
    println!("Did not panic");
}

It panics here:

parser.next().expect("unexpected new Parser error");

I don't know if it's intended or not, but the from_file returns a nice Result<> object. How would we feel about changing the signature of from<S: AsRef<str>>(s: S) -> Self to from<S: AsRef<str>>(s: S) -> Result<Self>?

if we're concerned about breaking the API here, we can always add an panic_safe_from<S: AsRef<str>>(s: S) -> Result<Self> and maybe deprecate the other.

Wdyt? Let me know which one of the above improvements you prefer and I'm more than happy to submit a PR.

func comments can't parse

/*
----------------abc-------------------------
test-abc[bcd]

*/
func _gen(){
}

just like the func comments, parse the comment is ""

bug: parsing of switch

The current tests for the switch aren't asserting the parsed AST is correct.
It is in fact, broken.

switch x {
    case 5:
     print(5)
}

This generates a switch statement without a tag.

https://github.com/chikaku/gosyn/blob/main/src/parser.rs#L1923

I believe this should be moved inside the if statement above.
Like so

if self.skipped(Operator::SemiColon)? {
              init = tag;

              tag = self
                  .current_not(Operator::BraceLeft)
                  .then(|| self.parse_simple_stmt())
                  .map_or(Ok(None), |r| r.map(Some))?;
          }

Because currently, the tag gets parsed correctly before this and it gets overwritten with None

feat: clone

Can we get the struct nodes to implement clone?

bug: function call arguments

Right now, this invalid code parses correctly.

a := 1
b := 2
foo(a b)

I believe, you need to do something like

                Some((_, Token::Operator(Operator::ParenLeft))) => {
                    self.next()?;
                    let mut args = vec![];
                    let mut prev_comma: Option<bool> = None;
                    while self.current_not(Operator::ParenRight)
                        && self.current_not(Operator::DotDotDot)
                    {
                        if let Some(pc) = prev_comma {
                            assert!(pc);
                        }
                        args.push(self.parse_next_level_expr()?);
                        prev_comma = Some(self.skipped(Operator::Comma)?);
                    }

I've added

let mut prev_comma: Option<bool> = None;

If there are more than 1 arguments, this will assert that there was a comma

performance

Hello,i am about to try to use this for a Go interpreter.
Can you identify where is the problematic utf8 decode, that you mentioned in the readme?

Comments on the same line of struct field cannot be located

After #3 merged, the parsing result of struct field can contain comments, but comments placed on the same line after type cannot be located accurately.

type Person struct {
    // ✅ this comment is ok
    name string

    age int // ❌ this comment can't be located
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.