-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar.html
98 lines (98 loc) · 10.7 KB
/
grammar.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Language Grammar - TMBASIC</title>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="apple-mobile-web-app-title" content="TMBASIC">
<meta name="application-name" content="TMBASIC">
<meta name="msapplication-TileColor" content="#da532c">
<style>
* { -webkit-text-size-adjust: none; text-size-adjust: none; }
a, a > span.tt { color: #326ec8; text-decoration: none; }
a:hover { text-decoration: underline; }
body { font-family: "Segoe UI", "Helvetica Neue", "Helvetica", Arial, sans-serif; font-size: 16px; color: #444444; margin: 1cm auto; margin-bottom: 5cm; padding-top: 1cm; max-width: 900px; line-height: 165%; overflow-y: scroll; }
col { width: auto !important; }
div.backlinks { font-size: 10pt; position: absolute; margin-top: -1cm; line-height: 100%; white-space: nowrap; }
div.bar { font-size: 9pt; margin-top: 20px; }
div.bar > span { background: #f8f8f8; padding: 5px 10px 5px 10px; font-weight: 500; }
div.code div { text-indent: -2cm; padding-left: 2cm; }
div.code { padding: 3mm; margin-bottom: 5mm; background: #f8f8f8; margin-top: 8px; white-space: pre; }
div.indent { margin-left: 1cm; }
div.paragraphBreak { height: 16px; }
div#root { margin-left: 1cm; margin-right: 1cm; }
div#compatibilityTable { line-height: 100%; }
div#compatibilityTable > table > tbody > tr > td { vertical-align: middle; padding: 2mm; padding-right: 4mm; }
h1 { font-size: 40px; color: #333333; }
h1 > span.tt { letter-spacing: -2px; word-break: break-word; }
h1#tmbasic { display: none; }
h1, h2, h3, h4, h5 { font-weight: 400; letter-spacing: -0.38px; line-height: 100%; }
h2 { font-size: 28px; color: #ba3925; margin-top: 50px; }
h3 { color: #ba3925; font-size: 20px; }
img.screenshot { margin-top: 2mm; height: 275px; width: 434px; float: right; margin-left: 1cm; margin-right: 1mm; background: #bbbbbb; image-rendering: -webkit-optimize-contrast; }
nav { background: #353535; position: absolute; top: 0; left: 0; width: 100%; padding-top: 2mm; padding-bottom: 2mm; line-height: normal; font-size: 18px; }
nav > div { max-width: 900px; margin: 0 auto; }
nav > div > div { margin-left: 1cm; margin-right: 1cm; }
nav > div > div > a { margin-left: 5mm; color: #afafaf; }
nav > div > div > a:hover { color: #FFFFFF; border-radius: 0.5mm; text-decoration: none; }
nav > div > div > a:first-child { margin-left: 0; padding-left: 0; color: #f7f7f7; }
pre, code, div.code, span.tt { font-family: Consolas, monospace; letter-spacing: -0.5px; color: #19177c; }
pre, div.code { line-height: 100%; overflow-x: auto; overflow-y: hidden; margin-top: 0; }
pre.diagram { display: inline-block; color: #333333; line-height: 100%; overflow-x: auto; overflow-y: hidden; width: 100%; }
pre.taste { background: #000080; color: white; padding: 5px 0px 5px 10px; line-height: 120%; }
pre.taste i { font-style: normal; color: #FFFF00; }
pre.taste b { font-weight: normal; color: #C0C0C0; }
pre.taste strong { font-weight: normal; color: #FF8AE2; }
pre.taste u { text-decoration: none; color: #00FFFF; }
span.comment, span.comment span.string { color: #26a135; }
span.indent { white-space: pre; }
span.operator { color: #666666; }
span.string { color: #ba2121; }
span.tt { line-height: 0; }
span#docLabelShort { display: none; }
strong, th { font-weight: 600; }
table { border-collapse: collapse; }
td, th { border: 1px solid #d5d5d5; padding: 1mm; padding-left: 3mm; padding-right: 4mm; vertical-align: top; }
th { text-align: left; }
ul { padding-left: 5mm; }
@media only screen and (max-width: 900px) and (min-width: 750px) {
h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
img.screenshot { height: 233.75px; width: 368.9px; /* 85% */ }
}
@media only screen and (max-width: 750px) {
h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
div#root { margin-left: 5mm; margin-right: 5mm; }
nav > div > div { margin-left: 5mm; margin-right: 5mm; }
div.backlinks { left: 5mm; }
h1, h2 { margin-left: 0; }
img.screenshot { float: none; margin-left: 0; margin-top: 0; height: 206.25px; width: 325.5px; /* 75% */ }
span#docLabelShort { display: inline; }
span#docLabelLong { display: none; }
}
@media only screen and (max-width: 350px) {
img.screenshot { height: 103.125px; width: 162.75px; /* 37.5% */ }
nav { zoom: 0.80; }
div.indent { margin-left: 0; }
span#docLabelShort { display: inline; }
span#docLabelLong { display: none; }
nav > div > div > a:first-child { font-size: 25px; }
}
</style>
</head>
<body>
<nav>
<div><div><a href="/" style="font-weight: 600;">TMBASIC</a><a href="doc.html"><span id="docLabelLong">Documentation</span><span id="docLabelShort">Docs</span></a><a href="https://github.com/tmbasic-lang/tmbasic">GitHub</a></div></div>
</nav>
<div id="root">
<div class="backlinks"><a href="doc.html">TMBASIC Documentation</a></div><h1>Language Grammar</h1><h2>Top Level</h2><ul><li>Program ::= Member*</li><li>Member ::= Subroutine | Function | DimStatement | ConstStatement | TypeDeclaration</li><li>Subroutine ::= "sub" identifier "(" ParameterList ")" "\n" Body "end" "sub" "\n"*</li><li>Function ::= "function" identifier "(" ParameterList ")" "as" Type "\n" Body "end" "function" "\n"*</li><li>TypeDeclaration ::= "type" identifier "\n" (Parameter "\n")* "end" "type" "\n"*</li><li>Statement ::= DeclarationStatement | BlockStatement | CommandStatement</li></ul><h2>Statements</h2><ul><li>Statement ::= CommandStatement | ForStatement | ForEachStatement | WhileStatement | DoStatement | IfStatement | SelectCaseStatement | TryStatement | DimStatement | DimCollectionStatement | ConstStatement</li><li>CommandStatement ::= AssignStatement | YieldStatement | ReturnStatement | CallStatement | ContinueStatement | ExitStatement | ThrowStatement | RethrowStatement | PrintStatement | InputStatement</li><li>AssignStatement ::= DottedExpression "=" Expression "\n"</li><li>ForStatement ::= "for" identifier "=" Expression "to" Expression ForStep? "\n" Body "next" "\n"</li><li>ForStep ::= "step" Expression</li><li>ForEachStatement ::= "for" "each" identifier "in" Expression "\n" Body "next" "\n"</li><li>WhileStatement ::= "while" Expression "\n" Body "wend" "\n"</li><li>IfStatement ::= "if" Expression "then" ("\n" Body ElseIf* Else? "end" "if" | CommandStatement) "\n"</li><li>ElseIf ::= "else" "if" Expression "then" "\n" Body</li><li>Else ::= "else" "\n" Body</li><li>DoStatement ::= "do" "\n" Body "loop" "while" Expression "\n"</li><li>SelectCaseStatement ::= "select" "case" Expression "\n" Case* "end" "select" "\n"</li><li>Case ::= "case" (CaseValueList | "else") "\n" Body</li><li>CaseValueList ::= CaseValue ("," CaseValue)*</li><li>CaseValue ::= Expression ("to" Expression)?</li><li>DeclarationStatement ::= DimStatement | ConstStatement</li><li>TryStatement ::= "try" "\n" Body "catch" "\n" Body "end" "try"</li><li>DimStatement ::= "dim" "shared"? identifier ("as" Type | "=" Expression) "\n"</li><li>DimCollectionStatement ::= "dim" ("list" | "map" | "set") identifier "\n" Body "end" "dim" "\n"</li><li>ConstStatement ::= "const" identifier "=" LiteralValue "\n"</li><li>YieldStatement ::= "yield" Expression ("to" Expression)? "\n"</li><li>ReturnStatement ::= "return" Expression? "\n"</li><li>CallStatement ::= identifier ArgumentList "\n"</li><li>ContinueStatement ::= "continue" ("do" | "for" | "while") "\n"</li><li>ExitStatement ::= "exit" ("do" | "for" | "while") "\n"</li><li>ThrowStatement ::= "throw" (Expression ",")? Expression "\n"</li><li>RethrowStatement ::= "rethrow" "\n"</li><li>PrintStatement ::= "print" Expression (";" Expression)* ";"? "\n"</li><li>InputStatement ::= "input" identifier "\n"</li><li>OnStatement ::= "on" identifier identifier "call" identifier "\n"</li></ul><h2>Expressions</h2><ul><li>Expression ::= OrExpression</li><li>OrExpression ::= AndExpression OrExpressionSuffix*</li><li>OrExpressionSuffix ::= "or" AndExpression</li><li>AndExpression ::= EqualityExpression AndExpressionSuffix*</li><li>AndExpressionSuffix ::= "and" EqualityExpression</li><li>EqualityExpression ::= InequalityExpression EqualityExpressionSuffix*</li><li>EqualityExpressionSuffix ::= ("=" | "<>") InequalityExpression</li><li>InequalityExpression ::= AddExpression InequalityExpressionSuffix*</li><li>InequalityExpressionSuffix ::= ("<" | "<=" | ">" | ">=") AddExpression</li><li>AddExpression ::= MultiplyExpression AddExpressionSuffix*</li><li>AddExpressionSuffix ::= ("+" | "-") MultiplyExpression</li><li>MultiplyExpression ::= ExponentExpression MultiplyExpressionSuffix*</li><li>MultiplyExpressionSuffix ::= ("*" | "/" | "mod") ExponentExpression</li><li>ExponentExpression ::= UnaryExpression ExponentExpressionSuffix*</li><li>ExponentExpressionSuffix ::= ("^") UnaryExpression</li><li>UnaryExpression ::= "not"? ConvertExpression</li><li>ConvertExpression ::= DottedExpression ("as" Type)?</li><li>DottedExpression ::= ExpressionTerm DottedExpressionSuffix*</li><li>DottedExpressionSuffix ::= "." identifier | "(" ArgumentList ")"</li><li>ExpressionTerm ::= LiteralValue | identifier | ParenthesesTerm | LiteralArrayTerm | LiteralRecordTerm | LiteralNoTerm</li><li>ParenthesesTerm ::= "(" Expression ")"</li><li>LiteralArrayTerm ::= "[" ArgumentList "]"</li><li>LiteralRecordTerm ::= "{" LiteralRecordFieldList "}"</li><li>LiteralNoTerm ::= "no" Type</li><li>LiteralRecordFieldList ::= (LiteralRecordField ("," LiteralRecordField)*)?</li><li>LiteralRecordField ::= identifier ":" Expression</li><li>LiteralValue ::= boolean | number | string</li></ul><h2>Type Signatures</h2><ul><li>Type ::= PrimitiveType | RecordType | ListType | MapType | SetType | OptionalType | NamedType</li><li>PrimitiveType ::= "boolean" | "number" | "string" | "date" | "datetime" | "datetimeoffset" | "timespan" | "timezone"</li><li>RecordType ::= "record" "(" ParameterList ")"</li><li>ListType ::= "list" "of" TypeWithParentheses</li><li>MapType ::= "map" "from" TypeWithParentheses "to" TypeWithParentheses</li><li>SetType ::= "set" "of" TypeWithParentheses</li><li>OptionalType ::= "optional" TypeWithParentheses</li><li>TypeWithParentheses ::= "(" Type ")" | Type</li><li>NamedType ::= identifier</li></ul><h2>Common</h2><ul><li>ParameterList ::= (Parameter ("," Parameter)*)?</li><li>Parameter ::= identifier "as" Type</li><li>ArgumentList ::= (Expression ("," Expression)*)?</li><li>Body ::= Statement*</li></ul><h2>Terminals</h2><ul><li>identifier ::= /[A-Za-z_][A-Za-z0-9_]*/</li><li>boolean ::= "true" | "false"</li><li>number ::= /-?[0-9]+\.?[0-9]*/</li><li>string ::= /"(""|[^"])*"/</li></ul>
</div>
</body>
</html>