Commit Graph

325 Commits

Author SHA1 Message Date
Vindaar
410254b485 fix issue #20922 by handling missing expr in exprList for tkOf (#20930)
* fix issue #20922 by handling missing expr in `exprList` for `tkOf`

* fix line numbers in test case

* rewrite exprList requiring expr, add optionalExprList for except

As suggested by @metagn.

* update test case to reflect new code

* update grammar.txt

* update line numbers in test case taking into account nimout

Given the number of errors that are produced it seems easier to do it
this way instead of using `tt.Error`.

(cherry picked from commit 0a1d4ba842)
2023-04-26 09:31:33 +02:00
hlaaftana
4857d9204e treat do with pragmas but no parens as proc (#19191)
fixes #19188

(cherry picked from commit 1ef945668d)
2023-04-24 17:28:15 +02:00
hlaaftana
c5df4ed62a fix #12274 (#19180)
(cherry picked from commit 2859069dbe)
2023-04-24 17:26:18 +02:00
Ivan Yonchovski
17d45dfd6a Implemented basic macro expand functionality (#20579)
* Implemented level based macro expand functionality

- it can handle single macro call or expand whole function/proc/etc and it

- In addition, I have altered the parser to provide the endInfo for the node.
The usefulness of the `endInfo` is not limited to the `expandMacro`
functionality but also it is useful for `ideOutline` functionality and I have
altered the ideOutline functionality to use `endInfo`. Note `endInfo` most of
the time is lost during the AST transformation thus in `nimsuggest.nim` I am
using freshly parsed tree to get the location information.

* Make sure we stop expanding correctly

* Test CI

* Fix tv3_outline.nim

(cherry picked from commit 7031ea65cd)
2023-01-31 10:23:52 +01:00
metagn
5cfa3672b3 allow proc expressions in place of statements (#20935)
properly fixes #18714

(cherry picked from commit 15d00ca0e1)
2022-11-30 07:31:35 +01:00
Andreas Rumpf
0648cde117 fixes grammar typos [backport] (#19289)
(cherry picked from commit a61bbf7d8d)
2021-12-31 05:13:52 +01:00
Andreas Rumpf
95dce90467 fixes #19011 [backport:1.6] (#19114)
(cherry picked from commit 6ff61766da)
2021-11-11 16:16:11 +01:00
Andreas Rumpf
c56ba3f06a fixes #18847 [backport] (#18870) 2021-09-20 09:09:53 +02:00
Andreas Rumpf
2e2d928846 formal grammar updates [backport:1.2] (#18803) 2021-09-04 19:52:57 +02:00
Timothee Cour
fa7c1aa864 move PNode.comment to a side channel, reducing memory usage during compilation by a factor 1.25x (#18760)
* move PNode.comment so a side channel, reducing memory usage

* fix a bug

* fixup

* use sfHasComment to speedup comment lookups

* fix for IC

* Update compiler/parser.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-08-29 15:54:07 +02:00
Timothee Cour
3aa16c1de0 fix RFC #341: dot-like operators are now parsed with same precedence as . (#18711)
* fix RFC #341: dot-like operators are now parsed with same precedence as `.`

* fixup

* [skip ci] address comment in changelog

* address comment

* update grammmar

* add manual entry

* fixup

* -d:nimPreviewDotLikeOps

* address comment to unblock PR: move nimPreviewDotLikeOps out of config/config.nims
2021-08-25 06:50:40 +02:00
Timothee Cour
8d2f6bba3a support same-line doc comments in routines (#18595)
* support same-line comments in routines
* remove assert as per review comment
2021-07-27 19:50:59 +02:00
konsumlamm
ac5435ecd0 Make error message for empty new-styled concept more descriptive (#18506)
* Allow empty new-styled concept

Slightly improve error messages

* Make empty new-styled concepts an error
2021-07-18 10:49:03 +02:00
Clyybber
72d6a9c885 Fix #16426 (#18377) 2021-06-28 17:41:37 +02:00
Clyybber
76f93877cd Small parser loop fix (#17904)
* Fix loop on error with nim check in semiStmtList
* Add test
2021-04-30 17:17:29 +02:00
Timothee Cour
08262206d3 refs #15667 improve invalid indentation errors, report when & where = could be missing (#16397)
* refs #15667 improve invalid indentation errors

* also show line info where = is missing

* add test

* add more tests
2021-04-10 08:55:39 +02:00
Araq
f5b1e384a4 parser.nim: simply layout change 2021-03-30 10:29:50 +02:00
Arne Döring
159c06e045 unify tuple expressions (#13793)
* unify tuple expressions

* fix test

* fix test

* apply feedback

* Handle empty tuples

* Fix rendering named unary tuple

* Protect static NimNode against stripping

* Slightly less hacky

* Revert "Slightly less hacky"

This reverts commit 170c5aec0addc029f637afbc948700ca006b7942.

* Slightly less hacky

* Cleanup

* Fix test

* Fix another test

* Add condsym

* Rebase fallout

* changelog: Move from compiler changes to language changes

* Add stricter tests

* Add empty tuple example to doc/astspec

* Fix test

Co-authored-by: Clyybber <darkmine956@gmail.com>
2021-03-30 02:06:51 +02:00
Andreas Rumpf
5f5a92379f custom integer literals (#17489)
* user defined integer literals; refs #17020
* updated renderer.nim
* use mlexerutils helper
* imported all test cases from https://github.com/nim-lang/Nim/pull/17020
* final grammar updated
2021-03-24 14:46:19 +01:00
Andreas Rumpf
6278b5d89a new-style concepts implementation, WIP (#15251)
* fixes #15210 [backport:1.2]

* make tests green
* make ordinal work
* makes Swapable test compile
* make Indexable example work
* concepts: 'self' is now 'Self'
* concepts: make Dictionary example compile
* document the new concept implementation
* concepts: make typeDesc work properly
* concepts: allow documentation comments (d'oh)
2021-02-24 13:17:33 +01:00
hlaaftana
def1f99289 add finally as post expr block [backport:1.4] (#16896) 2021-02-01 20:14:20 +01:00
Timothee Cour
6e267d28b3 remove conditionals on nimHasUserErrors, nimNoNilSeqs2, nimNoNilSeqs (#16861)
* cleanup docs for type(nil) | type(nil); simplify nimHasUserErrors

* simplify nimNoNilSeqs2

* simplify nimNoNilSeqs

* fixup
2021-01-29 14:30:24 +01:00
cooldome
00b495de95 Use modern enums in compiler (#15775) 2020-11-02 10:35:24 +01:00
Andreas Rumpf
92163fa330 implements https://github.com/nim-lang/RFCs/issues/258 (#15503)
* implements https://github.com/nim-lang/RFCs/issues/258

* don't be too strict with custom pragma blocks

* cast pragmas: documentation

* added most missing inference query procs to effecttraits.nim
2020-10-06 16:47:15 +02:00
Andreas Rumpf
7d8c1be8fb parser hotfix: don't run into endless loops; regression (#15468) 2020-10-02 18:26:52 +02:00
Clyybber
1881fc5812 Fix #15305 (#15311)
* Fix #15305

* Fix test
2020-09-12 12:39:46 +01:00
Clyybber
f3552b86c1 Better semiStmtList parsing (#15123)
* Better semiStmtList parsing
* Add examples from forums and wiki
* Move parseIfExpr near parseIfOrWhen
* Update grammar
2020-09-09 07:36:31 +02:00
Clyybber
35ff17410f Expand hoisted default params in sem (#15270)
* Expand hoisted default params in sem
Introduce ast.newTree{I,IT}
Add test for default params in procs

* Cleanup

* Simplify hoist transformation and expand test
2020-09-05 22:01:47 +02:00
Clyybber
13e659cfec Big compiler Cleanup (#14777) 2020-08-28 22:18:09 +02:00
Andreas Rumpf
4ab6887a67 fixes #15111 (#15136) 2020-08-01 07:39:00 +02:00
Andreas Rumpf
da29222f86 init checks and 'out' parameters (#14521)
* I don't care about observable stores
* enforce explicit initializations
* cleaner code for the stdlib
* stdlib: use explicit initializations
* make tests green
* algorithm.nim: set result explicitly
* remove out parameters and bring the PR into a mergable state
* updated the changelog
2020-06-23 10:53:57 +02:00
Araq
45bc6954c5 improve the parser's error message 2020-06-19 10:50:39 +02:00
Andreas Rumpf
75e579ff8e parser.nim: minor refactorings (#14540) 2020-06-01 19:04:28 +02:00
hlaaftana
de27910ab7 make from an operator (#14241) 2020-05-08 07:54:46 +02:00
Jasper Jenkins
796aafe7e0 make case-object transitions explicit, make unknownLineInfo a const, replace a few magic numbers with consts (#13170) 2020-01-17 10:34:31 +01:00
Andreas Rumpf
fadbd8f70d fixes #10665 (#13141) [backport] 2020-01-14 13:51:28 +01:00
Clyybber
7e747d11c6 Cosmetic compiler cleanup (#12718)
* Cleanup compiler code base

* Unify add calls

* Unify len invocations

* Unify range operators

* Fix oversight

* Remove {.procvar.} pragma

* initCandidate -> newCandidate where reasonable

* Unify safeLen calls
2019-11-28 17:13:04 +01:00
Federico Ceratto
39290cf88c Fix spellings (#12277) [backport] 2019-09-27 07:02:54 +02:00
Araq
6d8913ee14 nimpretty: fixes #11616 2019-07-18 12:13:22 +02:00
Araq
07d465ca42 [refactoring] remove unused imports in the compiler and in some stdlib modules 2019-07-18 00:36:03 +02:00
Araq
c94647aeca styleCheck: make the compiler and large parts of the stdlib compatible with --styleCheck:error 2019-07-10 12:42:41 +02:00
Araq
a59f0adc50 nimpretty: nimpretty now understands splitting newlines 2019-07-04 11:32:15 +02:00
Miran
f288e1b11a [bugfix] fix #11469, new rules for a newline in nimpretty (#11512)
* [bugfix] fix #11469, new rules for a newline in nimpretty
* concatenate two lines if they have the same indentation level
2019-06-26 15:36:44 +02:00
Araq
af39f26a3a [bugfix] nimpretty: fixes #11468 2019-06-13 10:42:37 +02:00
Andreas Rumpf
caf93f4355 nimpretty: smart tabs support, fixes #9399 [bugfix] 2019-06-10 10:50:15 +02:00
Araq
447cc1ff09 nimpretty: fixes #10295 2019-06-07 10:37:00 +02:00
cooldome
7d8af25d58 revert parser stmtListExpr (#11007)
* Revert "Support for stmtListExpr in parser after major keywords. Scaled down version. (#10852)"

This reverts commit 862897dc0f.

* redo fix for #4035

* render stmtlistExpr using semicolon

* Revert "render stmtlistExpr using semicolon"

This reverts commit cafb78b8d5.

* revert test
2019-04-17 11:55:41 +02:00
Miran
f309e4ff54 relax warning about inconsistent spacing (#10968)
Now the warning is raised only in the cases when there is an
inconsistency in the style (spacing vs no spacing):
* if a> b      --> warning
* if a >   b   --> no warning
2019-04-05 12:37:33 +02:00
Andreas Rumpf
8e1c6e2e2d fixes #10896 (#10903) 2019-03-25 19:26:38 +01:00
cooldome
28a926cb67 fixes #10861 (#10877) 2019-03-21 06:48:54 +01:00