diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-08-20 17:30:02 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-08-20 17:30:02 -0400 |
| commit | 0a922d3bca7fc65a9280f4869afce73a55b9c9cf (patch) | |
| tree | 6f249b48b859dcab45e28fad303db675e794d730 /doc | |
| parent | d5271d1e49338ef0e93c7eb88c0afda0dddcd19e (diff) | |
| download | zig-0a922d3bca7fc65a9280f4869afce73a55b9c9cf.tar.gz zig-0a922d3bca7fc65a9280f4869afce73a55b9c9cf.zip | |
move docs to website
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/langref.md | 176 | ||||
| -rw-r--r-- | doc/semantic_analysis.md | 1 | ||||
| -rw-r--r-- | doc/targets.md | 2 |
3 files changed, 1 insertions, 178 deletions
diff --git a/doc/langref.md b/doc/langref.md deleted file mode 100644 index ad9f39b214..0000000000 --- a/doc/langref.md +++ /dev/null @@ -1,176 +0,0 @@ -# Language Reference - -## Grammar - -``` -Root = many(TopLevelItem) "EOF" - -TopLevelItem = ErrorValueDecl | CompTimeExpression(Block) | TopLevelDecl | TestDecl - -TestDecl = "test" String Block - -TopLevelDecl = option(VisibleMod) (FnDef | ExternDecl | GlobalVarDecl | UseDecl) - -ErrorValueDecl = "error" Symbol ";" - -GlobalVarDecl = VariableDeclaration ";" - -VariableDeclaration = option("comptime") ("var" | "const") Symbol option(":" TypeExpr) "=" Expression - -ContainerMember = (ContainerField | FnDef | GlobalVarDecl) - -ContainerField = Symbol option(":" Expression) "," - -UseDecl = "use" Expression ";" - -ExternDecl = "extern" option(String) (FnProto | VariableDeclaration) ";" - -FnProto = option("coldcc" | "nakedcc" | "stdcallcc") "fn" option(Symbol) ParamDeclList option("->" TypeExpr) - -VisibleMod = "pub" | "export" - -FnDef = option("inline" | "extern") FnProto Block - -ParamDeclList = "(" list(ParamDecl, ",") ")" - -ParamDecl = option("noalias" | "comptime") option(Symbol ":") (TypeExpr | "...") - -Block = "{" many(Statement) option(Expression) "}" - -Statement = Label | VariableDeclaration ";" | Defer(Block) | Defer(Expression) ";" | BlockExpression(Block) | Expression ";" | ";" - -Label = Symbol ":" - -TypeExpr = PrefixOpExpression | "var" - -BlockOrExpression = Block | Expression - -Expression = ReturnExpression | BreakExpression | AssignmentExpression - -AsmExpression = "asm" option("volatile") "(" String option(AsmOutput) ")" - -AsmOutput = ":" list(AsmOutputItem, ",") option(AsmInput) - -AsmInput = ":" list(AsmInputItem, ",") option(AsmClobbers) - -AsmOutputItem = "[" Symbol "]" String "(" (Symbol | "->" TypeExpr) ")" - -AsmInputItem = "[" Symbol "]" String "(" Expression ")" - -AsmClobbers= ":" list(String, ",") - -UnwrapExpression = BoolOrExpression (UnwrapMaybe | UnwrapError) | BoolOrExpression - -UnwrapMaybe = "??" Expression - -UnwrapError = "%%" option("|" Symbol "|") Expression - -AssignmentExpression = UnwrapExpression AssignmentOperator UnwrapExpression | UnwrapExpression - -AssignmentOperator = "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | "&=" | "^=" | "|=" | "*%=" | "+%=" | "-%=" | "<<%=" - -BlockExpression(body) = Block | IfExpression(body) | TryExpression(body) | TestExpression(body) | WhileExpression(body) | ForExpression(body) | SwitchExpression | CompTimeExpression(body) - -CompTimeExpression(body) = "comptime" body - -SwitchExpression = "switch" "(" Expression ")" "{" many(SwitchProng) "}" - -SwitchProng = (list(SwitchItem, ",") | "else") "=>" option("|" option("*") Symbol "|") Expression "," - -SwitchItem = Expression | (Expression "..." Expression) - -ForExpression(body) = option("inline") "for" "(" Expression ")" option("|" option("*") Symbol option("," Symbol) "|") body option("else" BlockExpression(body)) - -BoolOrExpression = BoolAndExpression "or" BoolOrExpression | BoolAndExpression - -ReturnExpression = option("%") "return" option(Expression) - -BreakExpression = "break" option(Expression) - -Defer(body) = option("%") "defer" body - -IfExpression(body) = "if" "(" Expression ")" body option("else" BlockExpression(body)) - -TryExpression(body) = "if" "(" Expression ")" option("|" option("*") Symbol "|") body "else" "|" Symbol "|" BlockExpression(body) - -TestExpression(body) = "if" "(" Expression ")" option("|" option("*") Symbol "|") body option("else" BlockExpression(body)) - -WhileExpression(body) = option("inline") "while" "(" Expression ")" option("|" option("*") Symbol "|") option(":" "(" Expression ")") body option("else" option("|" Symbol "|") BlockExpression(body)) - -BoolAndExpression = ComparisonExpression "and" BoolAndExpression | ComparisonExpression - -ComparisonExpression = BinaryOrExpression ComparisonOperator BinaryOrExpression | BinaryOrExpression - -ComparisonOperator = "==" | "!=" | "<" | ">" | "<=" | ">=" - -BinaryOrExpression = BinaryXorExpression "|" BinaryOrExpression | BinaryXorExpression - -BinaryXorExpression = BinaryAndExpression "^" BinaryXorExpression | BinaryAndExpression - -BinaryAndExpression = BitShiftExpression "&" BinaryAndExpression | BitShiftExpression - -BitShiftExpression = AdditionExpression BitShiftOperator BitShiftExpression | AdditionExpression - -BitShiftOperator = "<<" | ">>" | "<<%" - -AdditionExpression = MultiplyExpression AdditionOperator AdditionExpression | MultiplyExpression - -AdditionOperator = "+" | "-" | "++" | "+%" | "-%" - -MultiplyExpression = CurlySuffixExpression MultiplyOperator MultiplyExpression | CurlySuffixExpression - -CurlySuffixExpression = TypeExpr option(ContainerInitExpression) - -MultiplyOperator = "*" | "/" | "%" | "**" | "*%" - -PrefixOpExpression = PrefixOp PrefixOpExpression | SuffixOpExpression - -SuffixOpExpression = PrimaryExpression option(FnCallExpression | ArrayAccessExpression | FieldAccessExpression | SliceExpression) - -FieldAccessExpression = "." Symbol - -FnCallExpression = "(" list(Expression, ",") ")" - -ArrayAccessExpression = "[" Expression "]" - -SliceExpression = "[" Expression ".." option(Expression) "]" - -ContainerInitExpression = "{" ContainerInitBody "}" - -ContainerInitBody = list(StructLiteralField, ",") | list(Expression, ",") - -StructLiteralField = "." Symbol "=" Expression - -PrefixOp = "!" | "-" | "~" | "*" | ("&" option("const") option("volatile")) | "?" | "%" | "%%" | "??" | "-%" - -PrimaryExpression = Integer | Float | String | CharLiteral | KeywordLiteral | GroupedExpression | GotoExpression | BlockExpression(BlockOrExpression) | Symbol | ("@" Symbol FnCallExpression) | ArrayType | (option("extern") FnProto) | AsmExpression | ("error" "." Symbol) | ContainerDecl - -ArrayType = "[" option(Expression) "]" option("const") TypeExpr - -GotoExpression = "goto" Symbol - -GroupedExpression = "(" Expression ")" - -KeywordLiteral = "true" | "false" | "null" | "continue" | "undefined" | "error" | "this" | "unreachable" - -ContainerDecl = option("extern" | "packed") ("struct" | "enum" | "union") "{" many(ContainerMember) "}" -``` - -## Operator Precedence - -``` -x() x[] x.y -!x -x -%x ~x *x &x ?x %x %%x ??x -x{} -* / % ** *% -+ - ++ +% -% -<< >> -& -^ -| -== != < > <= >= -and -or -?? %% -= *= /= %= += -= <<= >>= &= ^= |= -``` diff --git a/doc/semantic_analysis.md b/doc/semantic_analysis.md index 054563e022..770b0f93b3 100644 --- a/doc/semantic_analysis.md +++ b/doc/semantic_analysis.md @@ -21,7 +21,6 @@ level declarations are: * Function Definition * Global Variable Declaration * Container Declaration (struct or enum) - * Type Declaration * Error Value Declaration * Use Declaration diff --git a/doc/targets.md b/doc/targets.md index 8b4afe7be0..ca60c3280d 100644 --- a/doc/targets.md +++ b/doc/targets.md @@ -12,4 +12,4 @@ Write the target-specific code in the standard library. Update the C integer types to be the correct size for the target. -Make sure that `c_long_double` codegens the correct floating point value. +Make sure that `c_longdouble` codegens the correct floating point value. |
