Commit Graph

169 Commits

Author SHA1 Message Date
Adam Strzelecki
b0db8126a5 Parser: Inline expr pragmas with parenthesis
Previously pragmas could be attached only to whole statements, this change
allows attaching pragmas to inline statements, eg.:

  template rewriteAdd{a + b}(a: expr, b: expr): expr =
    ({.noRewrite.}: a + b) + 1

Code above will cause a + b to be rewritten once, because rewriteAdd attaches
{.noRewrite.} to resulting a + b expr.
2015-06-02 21:58:14 +02:00
Adam Strzelecki
2f5ed17cfe Parser: Properly represent parsePar in grammar 2015-06-02 21:53:46 +02:00
Araq
9e4e7ca535 fixes #2533 2015-04-24 12:36:41 +02:00
Andreas Rumpf
6a016743aa Merge pull request #2566 from nanoant/parser-diagnostic-location
Parser: Fix location (line, col) for diagnostics
2015-04-24 12:33:11 +02:00
Adam Strzelecki
07b13251d1 Parser: Fix location (line, col) for diagnostics
Previously parser was using lexMessage which was taking location from current
buffer position which was pointing after recently consumed token. But since
parser shows diagnostics about that token it should point to the location where
token starts.

This makes diagnostics like: `test.nim(2, 2) Error: ':' expected` point
properly at the beginning of the wrong token.
2015-04-21 11:32:13 +02:00
Adam Strzelecki
0da4d6b755 Parser: Make exprList() not comsume endToken
This makes use single comcol or eat for multiple cases. Also this makes
exprList responsible for consuming only list of expressions, nothing else which
is more logical.

As a side-effect compiler is now more consistent about errors, eg.:

    try # <- missing something
      echo "try"
    finally:
      echo "finally"

Triggers: test.nim(2, 6) Error: ':' expected

    try:
      echo "try"
    finally # <- missing something
      echo "finally"

Previously triggered: test.nim(4, 6) Error: invalid indentation

But now we got: Error: ':' expected - same as in 1st case
2015-04-20 21:06:03 +02:00
Adam Strzelecki
8a6df889d0 Parser: Use colcom(...) when possible
This make parsing obligatory colon more consistent across the parser's code.
2015-04-20 21:06:03 +02:00
Araq
2b4e233510 Merge branch 'devel' of https://github.com/Araq/Nim into devel 2015-04-20 11:44:54 +02:00
Araq
9abfc60db4 parse 'of' branches for macros properly 2015-04-19 14:25:16 +02:00
Andreas Rumpf
b4e938ca21 Merge pull request #2503 from ReneSac/arrowLike
Restrict arrow-like operators to those ending with `->`, `~>` or `=>`
2015-04-15 19:24:44 +02:00
ReneSac
06617bbb76 Minor fixes for arrow like change patch
Don't use ^ operator yet for compatibility with older compilers.
Moved arrow like explanation, and fix precedence description on the text in the manual.
Fixed typo in news.
2015-04-11 17:22:09 -03:00
ReneSac
34997292f4 Changing the rule for arrow like operators again. 2015-04-10 23:59:17 -03:00
Araq
10c1d7f519 minor lexer cleanups; fixes #2504 2015-04-10 14:03:48 +02:00
ReneSac
f15b4ccb52 Restrict arrow-like operators to start with - or = 2015-04-09 17:00:11 -03:00
ReneSac
80050a09a0 Refactored getPrecedence() after last change
The considerStrongSpaces() is now applied to almost all results, so it is better to do it at the end.
2015-04-08 02:06:18 -03:00
ReneSac
6a528bc7e9 Consider #!strongSpaces for keyword operators too.
When #!strongSpaces is on, every  operator affected by it gains priority higher than any operator not affected by it. This includes comparison operators, addition, etc.
It seems that counting spaces for keywords operators don't break anything in the parser. Of course, they can't have 0 spaces between their operands, but at least their precedence will work accordingly to their 1+ spaces.
2015-04-08 01:00:14 -03:00
Araq
e80840c40a preparations for dealing with the 'echo $foo' gotcha 2015-03-27 02:14:27 +01:00
Araq
e680e43fc2 fixes #2405 2015-03-25 14:50:08 +01:00
Araq
f6ff01572e breaking change: 'concept' is now a keyword and used instead of 'generic' 2015-03-23 13:10:18 +01:00
Araq
ca6906d85b fixes long standing parsing issue with command syntax 2015-03-22 01:38:14 +01:00
Araq
08c0ba379a fixes #1805 2015-03-21 20:38:28 +01:00
Max Zerzouri
9c126282b2 interpret tuple as a class and tuple[] as the empty tuple
When the indentation syntax is allowed it is always interpreted as a
tuple:

type
  Unit = tuple
2015-03-06 12:20:15 +13:00
Araq
ece23d39bc fixes #2123 2015-02-14 18:11:52 +01:00
Araq
c91ca82a43 fixes #2073; language spec change: arrow like operators are not right associative anymore 2015-02-08 13:38:06 +01:00
Araq
fe30ec83e2 nimsuggest improvements 2015-01-30 03:04:45 +01:00
Araq
26b853923c nimsuggest: first version 2015-01-27 01:36:19 +01:00
Araq
c87f1eb581 'discard' can be used instead of 'nil' for empty case object branches 2015-01-12 02:00:36 +01:00
Guillaume Gelin
3119fe087d Happy new year! 2015-01-06 15:26:33 +01:00
Araq
9280473eb1 fixes #1120 2014-12-25 17:22:41 +01:00
Araq
2be3f501a1 fixes #1742 2014-12-24 13:02:58 +01:00
Araq
59e279ba9c fixes a small bug concerning semicolons for top level statements 2014-12-23 23:08:37 +01:00
Araq
cd03f59432 implemented arrow like operators 2014-12-08 08:56:44 +01:00
Araq
e27ab36731 implements 'defer' 2014-12-04 10:12:32 +01:00
Araq
b2f577df23 fixes #1473 2014-11-12 02:36:59 +01:00
Araq
2781fea9e2 Nimrod renamed to Nim 2014-08-28 09:38:14 +02:00
Araq
2f43fdb837 renamefest 2014-08-23 01:43:49 +02:00
Araq
212293197f fixes #1161 2014-07-01 21:47:53 +02:00
flaviut
ce29b9f78c fix tokenizing bug 2014-06-08 19:41:36 -04:00
flaviut
145cb3ae8c fix overlooked grammer comment 2014-06-08 15:46:19 -04:00
flaviut
6b9359d901 updated grammer, fixed oversight 2014-06-04 15:40:31 -04:00
flaviut
90dc35c109 fix bug with unexpected tkInvalid,tkEof,tkComment 2014-06-04 15:30:37 -04:00
flaviut
7a9bcf4769 Clean up code 2014-06-03 19:05:12 -04:00
flaviut
20cb567bf5 Fix accents in enums 2014-06-03 14:15:32 -04:00
flaviut
3db3c0e382 Generalize accent parsing 2014-06-03 10:12:31 -04:00
Clay Sweetser
3afbe24b7c Document parser structures and procedures. 2014-05-25 01:50:23 -04:00
Araq
b961e47bfe new concurrency model: first steps; shared is not a keyword anymore 2014-04-14 08:45:43 +02:00
Araq
d96f25619a implemented 'R ptr T' syntax 2014-04-13 22:31:49 +02:00
Araq
9fdb131686 fixes #992 2014-03-26 16:22:34 +01:00
Zahary Karadjov
8a0509b3b2 implements `distinct with/without X, Y`
This still doesn't work quite right, because some common operations like array
indexing lay completely outside the scope/symbol lookup system - they are not
even magics.
2014-03-20 01:16:50 +02:00
Zahary Karadjov
7080d02af4 allow multi-line expressions using the dot operator
this enables parsing of expressions like:

``` Nimrod
s.items
  .map(proc (x): auto = x * 2)
  .filter do (x) -> auto:
    return x % 2 == 0
  .group_by((x) => x.length)
```
2014-03-16 20:42:06 +02:00