Commit Graph

14 Commits

Author SHA1 Message Date
Kasey White
0da4560792 fix failing unit tests 2023-01-17 03:02:06 -05:00
KtorZ
844570caf5 Fix multi-line type-alias tuple definitions
Somehow missed it when reworking tuples. We need to allow the new
  'NewLineLeftParen' token in this situation as well. Especially because
  this is what the formatter outputs.
2023-01-16 11:30:20 +01:00
KtorZ
5b7147fc43 Remove leading '#' for tuple definitions.
This possibly breaks many Aiken programs out there, but it's for the
  best. We haven't released the alpha yet so we still have a bit of
  freedom when it comes to breaking change.

  Plus, the migration path is easy, simply run:

  ```
  find . -name "*.ak" | xargs sed -i "s/#(/(/g"
  ```

  (or `-i ''` on MacOS).
2023-01-14 20:22:19 +01:00
KtorZ
2d99c07dd3 Support (and default to) parenthesis for block expressions
This changes allow to use parenthesis `(` `)` to encapsulate
  expressions in addition to braces `{` `}` used to define blocks.

  The main use-case is for arithmetic and boolean expressions for which
  developers are used to using parenthesis. For example:

  ```
  { 14 + 42 } * 1337
  ```

  can now be written as:

  ```
  ( 14 + 42 ) * 1337
  ```

  This may sound straightforward at first but wasn't necessarily trivial
  in Aiken given that (a) everything is an expression, (b) whitespaces
  do not generally matter and (c) there's no symbol indicating the end
  of a 'statement' (because there's no statement).

  Thus, we have to properly disambiguate between:

  ```
  let foo = bar(14 + 42)
  ```

  and

  ```
  let foo = bar
  (14 + 42)
  ```

  Before this commit, the latter would be interpreted as a function call
  and would lead to a somewhat puzzling error. Now, the newline serves
  as a delimiting symbol. The trade-off being that for a function call,
  the left parenthesis has to be on the same line as the function name
  identifier -- which is a fair trade off. So this is still allowed:

  ```
  let foo = bar(
    14 + 42
  )
  ```

  As there's very little ambiguity about it.

  This fixes #236 and would seemingly allow us to get rid of the leading
  `#` in front of tuples.
2023-01-14 11:49:45 -05:00
KtorZ
3139c85fe8 Support declaring bytearray literals as base16 strings. 2022-12-29 13:08:58 +01:00
KtorZ
f2e716dd86 Fix else/if formatter. 2022-12-28 17:55:11 +01:00
KtorZ
bae8267f18 Fix formatter for unary operation
Was wrongly converting any unary operation into '!'
2022-12-28 17:51:00 +01:00
KtorZ
1f15c2ca20 Sort import alphabetically when formatting.
Fixes #211.
2022-12-22 18:00:25 +01:00
KtorZ
1ca705005d Fix formatting of if-expressions
Fixes #129.
2022-12-22 16:51:23 +01:00
KtorZ
7ad8babf17 Rename ArgName::{Discard,NamedLabeled} as ArgName::{Discarded,Named}
Now that the other variants are gone, this is clearer.
2022-12-22 09:36:44 +01:00
KtorZ
8ab05509b1 Remove Named & DiscardLabeled, now unused
And unify everything into either 'Discard' or 'NamedLabeled'
2022-12-22 09:36:44 +01:00
KtorZ
bf7cdfba73 Implement parser & type-checker for tuple indexes.
```aiken
  fn foo() {
    let tuple = #(1, 2, 3, 4)
    tuple.1st + tuple.2nd + tuple.3rd + tuple.4th
  }
  ```
2022-12-22 09:14:23 +01:00
rvcas
4c4e454ea3 feat: all function args are now labeled implicitly 2022-12-21 19:17:15 -05:00
rvcas
42204d2d71 chore: make folder names match crate name 2022-12-21 18:11:07 -05:00