vapourlang / vapour

Typed superset of R
http://vapour.run
Apache License 2.0
190 stars 3 forks source link

Newline sensitivity #68

Closed maxim-h closed 1 month ago

maxim-h commented 1 month ago

Hi! Thanks for the cool project.

When I tried using vapour, first thing I noticed is that I can't define a type in a one-liner:

type t: object { x: int, y: int }

Transpiling produces the following error:

$ vapour -infile=test.vp -outfile=test.r
[ERROR] test.vp:1:1 expected next token to be `colon`, got `end of file` instead
x failed to transpile files!

It seems to be the closing bracket that breaks things, because this works:

type t: object { x: int, y: int 
}

One would expect the newlines to be treated the same way as spaces and just separate the tokens.

Is that intended or is it just a bug?

JohnCoene commented 1 month ago

This is a bug, thank you for reporting it.

One would expect the newlines to be treated the same way as spaces and just separate the tokens.

That's not right though, the lexer does not emit token for spaces, they have no meaning or value in the tree downstream. The lexer does emit new lines though.

maxim-h commented 1 month ago

Ah, true. Thanks for the explanation! I guess I was only thinking about newlines within a single statement. Of course you still need newlines to separate multiple statements.