authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-20 17:30:02-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-20 17:30:02-04:00
log0a922d3bca7fc65a9280f4869afce73a55b9c9cf
tree6f249b48b859dcab45e28fad303db675e794d730
parentd5271d1e49338ef0e93c7eb88c0afda0dddcd19e

move docs to website


4 files changed, 2 insertions(+), 179 deletions(-)

doc/langref.md deleted-176
...@@ -1,176 +0,0 @@
1# Language Reference
2
3## Grammar
4
5```
6Root = many(TopLevelItem) "EOF"
7
8TopLevelItem = ErrorValueDecl | CompTimeExpression(Block) | TopLevelDecl | TestDecl
9
10TestDecl = "test" String Block
11
12TopLevelDecl = option(VisibleMod) (FnDef | ExternDecl | GlobalVarDecl | UseDecl)
13
14ErrorValueDecl = "error" Symbol ";"
15
16GlobalVarDecl = VariableDeclaration ";"
17
18VariableDeclaration = option("comptime") ("var" | "const") Symbol option(":" TypeExpr) "=" Expression
19
20ContainerMember = (ContainerField | FnDef | GlobalVarDecl)
21
22ContainerField = Symbol option(":" Expression) ","
23
24UseDecl = "use" Expression ";"
25
26ExternDecl = "extern" option(String) (FnProto | VariableDeclaration) ";"
27
28FnProto = option("coldcc" | "nakedcc" | "stdcallcc") "fn" option(Symbol) ParamDeclList option("->" TypeExpr)
29
30VisibleMod = "pub" | "export"
31
32FnDef = option("inline" | "extern") FnProto Block
33
34ParamDeclList = "(" list(ParamDecl, ",") ")"
35
36ParamDecl = option("noalias" | "comptime") option(Symbol ":") (TypeExpr | "...")
37
38Block = "{" many(Statement) option(Expression) "}"
39
40Statement = Label | VariableDeclaration ";" | Defer(Block) | Defer(Expression) ";" | BlockExpression(Block) | Expression ";" | ";"
41
42Label = Symbol ":"
43
44TypeExpr = PrefixOpExpression | "var"
45
46BlockOrExpression = Block | Expression
47
48Expression = ReturnExpression | BreakExpression | AssignmentExpression
49
50AsmExpression = "asm" option("volatile") "(" String option(AsmOutput) ")"
51
52AsmOutput = ":" list(AsmOutputItem, ",") option(AsmInput)
53
54AsmInput = ":" list(AsmInputItem, ",") option(AsmClobbers)
55
56AsmOutputItem = "[" Symbol "]" String "(" (Symbol | "->" TypeExpr) ")"
57
58AsmInputItem = "[" Symbol "]" String "(" Expression ")"
59
60AsmClobbers= ":" list(String, ",")
61
62UnwrapExpression = BoolOrExpression (UnwrapMaybe | UnwrapError) | BoolOrExpression
63
64UnwrapMaybe = "??" Expression
65
66UnwrapError = "%%" option("|" Symbol "|") Expression
67
68AssignmentExpression = UnwrapExpression AssignmentOperator UnwrapExpression | UnwrapExpression
69
70AssignmentOperator = "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | "&=" | "^=" | "|=" | "*%=" | "+%=" | "-%=" | "<<%="
71
72BlockExpression(body) = Block | IfExpression(body) | TryExpression(body) | TestExpression(body) | WhileExpression(body) | ForExpression(body) | SwitchExpression | CompTimeExpression(body)
73
74CompTimeExpression(body) = "comptime" body
75
76SwitchExpression = "switch" "(" Expression ")" "{" many(SwitchProng) "}"
77
78SwitchProng = (list(SwitchItem, ",") | "else") "=>" option("|" option("*") Symbol "|") Expression ","
79
80SwitchItem = Expression | (Expression "..." Expression)
81
82ForExpression(body) = option("inline") "for" "(" Expression ")" option("|" option("*") Symbol option("," Symbol) "|") body option("else" BlockExpression(body))
83
84BoolOrExpression = BoolAndExpression "or" BoolOrExpression | BoolAndExpression
85
86ReturnExpression = option("%") "return" option(Expression)
87
88BreakExpression = "break" option(Expression)
89
90Defer(body) = option("%") "defer" body
91
92IfExpression(body) = "if" "(" Expression ")" body option("else" BlockExpression(body))
93
94TryExpression(body) = "if" "(" Expression ")" option("|" option("*") Symbol "|") body "else" "|" Symbol "|" BlockExpression(body)
95
96TestExpression(body) = "if" "(" Expression ")" option("|" option("*") Symbol "|") body option("else" BlockExpression(body))
97
98WhileExpression(body) = option("inline") "while" "(" Expression ")" option("|" option("*") Symbol "|") option(":" "(" Expression ")") body option("else" option("|" Symbol "|") BlockExpression(body))
99
100BoolAndExpression = ComparisonExpression "and" BoolAndExpression | ComparisonExpression
101
102ComparisonExpression = BinaryOrExpression ComparisonOperator BinaryOrExpression | BinaryOrExpression
103
104ComparisonOperator = "==" | "!=" | "<" | ">" | "<=" | ">="
105
106BinaryOrExpression = BinaryXorExpression "|" BinaryOrExpression | BinaryXorExpression
107
108BinaryXorExpression = BinaryAndExpression "^" BinaryXorExpression | BinaryAndExpression
109
110BinaryAndExpression = BitShiftExpression "&" BinaryAndExpression | BitShiftExpression
111
112BitShiftExpression = AdditionExpression BitShiftOperator BitShiftExpression | AdditionExpression
113
114BitShiftOperator = "<<" | ">>" | "<<%"
115
116AdditionExpression = MultiplyExpression AdditionOperator AdditionExpression | MultiplyExpression
117
118AdditionOperator = "+" | "-" | "++" | "+%" | "-%"
119
120MultiplyExpression = CurlySuffixExpression MultiplyOperator MultiplyExpression | CurlySuffixExpression
121
122CurlySuffixExpression = TypeExpr option(ContainerInitExpression)
123
124MultiplyOperator = "*" | "/" | "%" | "**" | "*%"
125
126PrefixOpExpression = PrefixOp PrefixOpExpression | SuffixOpExpression
127
128SuffixOpExpression = PrimaryExpression option(FnCallExpression | ArrayAccessExpression | FieldAccessExpression | SliceExpression)
129
130FieldAccessExpression = "." Symbol
131
132FnCallExpression = "(" list(Expression, ",") ")"
133
134ArrayAccessExpression = "[" Expression "]"
135
136SliceExpression = "[" Expression ".." option(Expression) "]"
137
138ContainerInitExpression = "{" ContainerInitBody "}"
139
140ContainerInitBody = list(StructLiteralField, ",") | list(Expression, ",")
141
142StructLiteralField = "." Symbol "=" Expression
143
144PrefixOp = "!" | "-" | "~" | "*" | ("&" option("const") option("volatile")) | "?" | "%" | "%%" | "??" | "-%"
145
146PrimaryExpression = Integer | Float | String | CharLiteral | KeywordLiteral | GroupedExpression | GotoExpression | BlockExpression(BlockOrExpression) | Symbol | ("@" Symbol FnCallExpression) | ArrayType | (option("extern") FnProto) | AsmExpression | ("error" "." Symbol) | ContainerDecl
147
148ArrayType = "[" option(Expression) "]" option("const") TypeExpr
149
150GotoExpression = "goto" Symbol
151
152GroupedExpression = "(" Expression ")"
153
154KeywordLiteral = "true" | "false" | "null" | "continue" | "undefined" | "error" | "this" | "unreachable"
155
156ContainerDecl = option("extern" | "packed") ("struct" | "enum" | "union") "{" many(ContainerMember) "}"
157```
158
159## Operator Precedence
160
161```
162x() x[] x.y
163!x -x -%x ~x *x &x ?x %x %%x ??x
164x{}
165* / % ** *%
166+ - ++ +% -%
167<< >>
168&
169^
170|
171== != < > <= >=
172and
173or
174?? %%
175= *= /= %= += -= <<= >>= &= ^= |=
176```
doc/semantic_analysis.md-1
...@@ -21,7 +21,6 @@ level declarations are:...@@ -21,7 +21,6 @@ level declarations are:
21 * Function Definition21 * Function Definition
22 * Global Variable Declaration22 * Global Variable Declaration
23 * Container Declaration (struct or enum)23 * Container Declaration (struct or enum)
24 * Type Declaration
25 * Error Value Declaration24 * Error Value Declaration
26 * Use Declaration25 * Use Declaration
2726
doc/targets.md+1-1
...@@ -12,4 +12,4 @@ Write the target-specific code in the standard library....@@ -12,4 +12,4 @@ Write the target-specific code in the standard library.
1212
13Update the C integer types to be the correct size for the target.13Update the C integer types to be the correct size for the target.
1414
15Make sure that `c_long_double` codegens the correct floating point value.15Make sure that `c_longdouble` codegens the correct floating point value.
src/main.cpp+1-1
...@@ -91,7 +91,7 @@ static const char *ZIG_ZEN = "\n"...@@ -91,7 +91,7 @@ static const char *ZIG_ZEN = "\n"
91" * Avoid local maximums.\n"91" * Avoid local maximums.\n"
92" * Reduce the amount one must remember.\n"92" * Reduce the amount one must remember.\n"
93" * Minimize energy spent on coding style.\n"93" * Minimize energy spent on coding style.\n"
94" * Together we serve the end users.\n";94" * Together we serve end users.\n";
9595
96static int print_target_list(FILE *f) {96static int print_target_list(FILE *f) {
97 ZigTarget native;97 ZigTarget native;