Fix error messages for some illegal constructions, fix absolute path includes #742

Merged
zxq9 merged 8 commits from github/fork/radrow/error-msgs into lima 2020-03-30 21:52:17 +09:00
Showing only changes of commit 01a64b0367 - Show all commits

View File

@ -446,6 +446,13 @@ Example syntax:
// yields [12,13,14,20,21,22,30,31,32] // yields [12,13,14,20,21,22,30,31,32]
``` ```
Lists can be constructed using the range syntax using special `..` operator:
```
[1..4] == [1,2,3,4]
```
The ranges are always ascending and have step equal to 1.
Please refer to the [standard library](sophia_stdlib.md#List) for the predefined functionalities. Please refer to the [standard library](sophia_stdlib.md#List) for the predefined functionalities.
### Maps and records ### Maps and records
@ -825,15 +832,17 @@ In describing the syntax below, we use the following conventions:
A Sophia file consists of a sequence of *declarations* in a layout block. A Sophia file consists of a sequence of *declarations* in a layout block.
```c ```c
File ::= Block(Decl) File ::= Block(TopDecl)
Decl ::= ['payable'] 'contract' Con '=' Block(Decl)
TopDecl ::= ['payable'] 'contract' Con '=' Block(Decl)
| 'namespace' Con '=' Block(Decl) | 'namespace' Con '=' Block(Decl)
| '@compiler' PragmaOp Version | '@compiler' PragmaOp Version
| 'include' String | 'include' String
| 'type' Id ['(' TVar* ')'] ['=' TypeAlias]
Decl ::= 'type' Id ['(' TVar* ')'] '=' TypeAlias
| 'record' Id ['(' TVar* ')'] '=' RecordType | 'record' Id ['(' TVar* ')'] '=' RecordType
| 'datatype' Id ['(' TVar* ')'] '=' DataType | 'datatype' Id ['(' TVar* ')'] '=' DataType
| EModifier* ('entrypoint' | 'function') Block(FunDecl) | (EModifier* 'entrypoint' | FModifier* 'function') Block(FunDecl)
FunDecl ::= Id ':' Type // Type signature FunDecl ::= Id ':' Type // Type signature
| Id Args [':' Type] '=' Block(Stmt) // Definition | Id Args [':' Type] '=' Block(Stmt) // Definition
@ -945,6 +954,7 @@ Expr ::= '(' LamArgs ')' '=>' Block(Stmt) // Anonymous function (x) => x +
| '[' Sep(Expr, ',') ']' // List [1, 2, 3] | '[' Sep(Expr, ',') ']' // List [1, 2, 3]
| '[' Expr '|' Sep(Generator, ',') ']' | '[' Expr '|' Sep(Generator, ',') ']'
// List comprehension [k | x <- [1], if (f(x)), let k = x+1] // List comprehension [k | x <- [1], if (f(x)), let k = x+1]
| '[' Expr '..' Expr ']' // List range [1..n]
| '{' Sep(FieldUpdate, ',') '}' // Record or map value {x = 0, y = 1}, {[key] = val} | '{' Sep(FieldUpdate, ',') '}' // Record or map value {x = 0, y = 1}, {[key] = val}
| '(' Expr ')' // Parens (1 + 2) * 3 | '(' Expr ')' // Parens (1 + 2) * 3
| Id | Con | QId | QCon // Identifiers x, None, Map.member, AELib.Token | Id | Con | QId | QCon // Identifiers x, None, Map.member, AELib.Token