-
Notifications
You must be signed in to change notification settings - Fork 0
/
organizacao.txt
44 lines (43 loc) · 2.74 KB
/
organizacao.txt
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
Organização da gramática
Program = { Annot } ClassDec { { Annot } ClassDec }
Annot = “@” Id [ “(” { AnnotParam } “)” ]
AnnotParam = IntValue | StringValue | Id
IntValue = Digit { Digit }
Digit = “0” | ... | “9”
ClassDec = [ “open” ] “class” Id [ “extends” Id ] “{” MemberList “}”
MemberList = { [ Qualifier ] Member }
Qualifier = “private” | “public” | “override” | “override” “public” | “final” | “final” “public” | “final” “override” | “final” “override” “public”
Member = FieldDec | MethodDec
FieldDec = “var” Type IdList “;”
Type = BasicType | Id
BasicType = “Int” | “Boolean” | “String”
IdList = Id { “,” Id }
MethodDec = “func” IdColon FormalParamDec [ “->” Type ] “{” StatementList “}” | “func” Id [ “->” Type ] “{” StatementList “}”
FormalParamDec = ParamDec { “,” ParamDec }
ParamDec = Type Id
StatementList = { Statement }
Statement = AssignExpr “;” | IfStat | WhileStat | ReturnStat “;” | WriteStat “;” | “break” “;” | “;” | RepeatStat “;” | LocalDec “;” | AssertStat “;”
AssignExpr = Expression [ “=” Expression ]
Expression = SimpleExpression [ Relation SimpleExpression ]
SimpleExpression = SumSubExpression { “++” SumSubExpression }
SumSubExpression = Term { LowOperator Term }
Term = SignalFactor { HighOperator SignalFactor }
HighOperator = “∗” | “/” | “&&”
LowOperator = “+” | “−” | “||”
SignalFactor = [ Signal ] Factor
Signal = “+” | “−”
Factor = BasicValue | “(” Expression “)” | “!” Factor | “nil” | ObjectCreation | PrimaryExpr
BasicValue = IntValue | BooleanValue | StringValue
BooleanValue = “true” | “false”
ObjectCreation = Id “.” “new”
PrimaryExpr = “super” “.” IdColon ExpressionList | “super” “.” Id | Id | Id “.” Id | Id “.” IdColon ExpressionList | “self” | “self” “.” Id | “self” ”.” IdColon ExpressionList | “self” ”.” Id “.” IdColon ExpressionList | “self” ”.” Id “.” Id | ReadExpr
ExpressionList = Expression { “,” Expression }
ReadExpr = “In” “.” [ “readInt” | “readString” ]
Relation = “==” | “<” | “>” | “<=” | “>=” | “! =”
IfStat = “if” Expression “{” Statement “}” [ “else” “{” Statement “}” ]
WhileStat = “while” Expression “{” StatementList “}”
ReturnStat = “return” Expression
WriteStat = “Out” “.” [ “print:” | “println:” ] Expression
RepeatStat = “repeat” StatementList “until” Expression
LocalDec = “var” Type IdList [ “=” Expression ] “;”
AssertStat = “assert” Expression “,” StringValue