Skip to content

Commit e07514e

Browse files
committed
update ANTLR to 4.10 (mini breaking change)
small changes in testcases rework decls, still commented-out
1 parent ed5220f commit e07514e

File tree

11 files changed

+1004
-2255
lines changed

11 files changed

+1004
-2255
lines changed

Documentation/almost_never_auto.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,9 @@ auto does one good thing for readability, it's very easy to spot variable declar
143143
Contrary to C++, the initialization with the = sign can now communicate its type to the right side.
144144
MyClass myC = new();
145145
The new can not deduce ...??
146+
147+
148+
[magic-return-val=ret]
149+
[magic-param-val=other]
150+
[magic-param-ref=other]
151+
[magic-param-ptr=that]

backend/Grammar/Generated/Myll/MyllLexer.cs

Lines changed: 451 additions & 1099 deletions
Large diffs are not rendered by default.

backend/Grammar/Generated/Myll/MyllParser.cs

Lines changed: 428 additions & 1083 deletions
Large diffs are not rendered by default.

backend/Grammar/Generated/Myll/MyllParserBaseVisitor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was generated by a tool.
4-
// ANTLR Version: 4.9.2
4+
// ANTLR Version: 4.10.1
55
//
66
// Changes to this file may cause incorrect behavior and will be lost if
77
// the code is regenerated.
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// Generated from /home/sor/myll/backend/Grammar/MyllParser.g4 by ANTLR 4.9.2
11+
// Generated from /home/sor/myll/backend/Grammar/MyllParser.g4 by ANTLR 4.10.1
1212

1313
// Unreachable code detected
1414
#pragma warning disable 0162
@@ -31,7 +31,7 @@ namespace Myll {
3131
/// of the available methods.
3232
/// </summary>
3333
/// <typeparam name="Result">The return type of the visit operation.</typeparam>
34-
[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.9.2")]
34+
[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.10.1")]
3535
[System.Diagnostics.DebuggerNonUserCode]
3636
[System.CLSCompliant(false)]
3737
public partial class MyllParserBaseVisitor<Result> : AbstractParseTreeVisitor<Result>, IMyllParserVisitor<Result> {

backend/Grammar/Generated/Myll/MyllParserVisitor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was generated by a tool.
4-
// ANTLR Version: 4.9.2
4+
// ANTLR Version: 4.10.1
55
//
66
// Changes to this file may cause incorrect behavior and will be lost if
77
// the code is regenerated.
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// Generated from /home/sor/myll/backend/Grammar/MyllParser.g4 by ANTLR 4.9.2
11+
// Generated from /home/sor/myll/backend/Grammar/MyllParser.g4 by ANTLR 4.10.1
1212

1313
// Unreachable code detected
1414
#pragma warning disable 0162
@@ -29,7 +29,7 @@ namespace Myll {
2929
/// by <see cref="MyllParser"/>.
3030
/// </summary>
3131
/// <typeparam name="Result">The return type of the visit operation.</typeparam>
32-
[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.9.2")]
32+
[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.10.1")]
3333
[System.CLSCompliant(false)]
3434
public interface IMyllParserVisitor<Result> : IParseTreeVisitor<Result> {
3535
/// <summary>

backend/Grammar/MyllLexer.g4

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ COPY : 'copy';
213213

214214
ID : ALPHA_ ALNUM_*;
215215

216+
// The keywords "ret, result, other, that" are not really keywords,
217+
// they exist only in special spots and depending on context,
218+
// and they are handled by "id"
216219
NUL : 'null'|'nullptr'; // nullptr obsolete?
220+
//CLASS_LIT : 'this'|'self'|'base'|'super';
217221
CLASS_LIT : 'this'|'that'|'self'|'other'|'base'|'super'; // 'ret'?, maybe its not good that other etc are in here
218222
BOOL_LIT : 'true'|'false';
219223
FLOAT_LIT : ( DIGIT* '.' DIGIT+ ( [eE] [+-]? DIGIT+ )?

backend/Grammar/MyllParser.g4

Lines changed: 88 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ imports : IMPORT id (COMMA id)* COMMA? SEMI;
1010
//defines : DEFINITION id (COMMA id)* COMMA? SEMI;
1111

1212
// ONLY refer to levStmt, NOT the inStmt
13+
// rename to decl?
1314
levDecl : attribBlk LCURLY levDecl* RCURLY # AttribDeclBlock // must be in here, since it MUST have an attrib block
1415
| attribBlk COLON # AttribState // everything needs an antonym to make this work
1516
| attribBlk? inDecl # AttribDecl;
@@ -26,72 +27,108 @@ attribId : id | CONST | FALL | THROW | DEFAULT;
2627

2728
/*
2829
// DON'T refer to inDecl, ONLY refer to levDecl
29-
// ns, class, enum, func, ppp, c/dtor, alias, static
30-
inDeclX : ALIAS declAlias
31-
| ASPECT declAspect
32-
| CONCEPT declConcept
33-
| CONVERT declConvert
34-
| CTOR declCtor
35-
| DTOR declDtor
36-
| ENUM declEnum
37-
| NAMESPACE declNS
38-
| OPERATOR declOp
39-
| USING declUsing
40-
| declFunc
41-
| declStruct
42-
| declVar
30+
inDecl : declNamespace
31+
| declUsing
32+
| declAlias
33+
| declAspect // TODO
34+
| declConcept // TODO
35+
| declEnum
36+
| declStruct
37+
| declConvert
38+
| declCtor
39+
| declDtor
40+
| declFunc
41+
| declOp
42+
| declVar
4343
;
4444
45-
declNS : id (SCOPE id)*
45+
declNamespace: NAMESPACE ( defNamespace );
46+
declUsing : USING ( defUsing SEMI | LCURLY attrUsing* RCURLY );
47+
declAlias : ALIAS ( defAlias SEMI | LCURLY attrAlias* RCURLY );
48+
declAspect : ASPECT ( defAspect );
49+
declConcept : CONCEPT ( defConcept );
50+
declEnum : ENUM ( defEnum );
51+
declStruct : kindOfStruct( defStruct );
52+
declConvert : CONVERT ( defConvert | LCURLY attrConvert* RCURLY );
53+
declCtor : CTOR ( defCtor | LCURLY attrCtor* RCURLY );
54+
declDtor : DTOR ( defDtor );
55+
declFunc : kindOfFunc ( defFunc | LCURLY attrFunc* RCURLY );
56+
declOp : OPERATOR ( defOp | LCURLY attrOp* RCURLY );
57+
declVar : kindOfVar ( defVar | LCURLY attrVar* RCURLY );
58+
59+
kindOfStruct: STRUCT | CLASS | UNION;
60+
kindOfFunc : FUNC | PROC | METHOD;
61+
kindOfVar : VAR | FIELD | CONST | LET;
62+
63+
kindOfPassing: COPY | MOVE | FORWARD;
64+
65+
attrUsing : defUsing | attribBlk ( defUsing | LCURLY attrUsing* RCURLY | COLON );
66+
attrAlias : defAlias | attribBlk ( defAlias | LCURLY attrAlias* RCURLY | COLON );
67+
attrConvert : defConvert | attribBlk ( defConvert | LCURLY attrConvert* RCURLY | COLON );
68+
attrCtor : defCtor | attribBlk ( defCtor | LCURLY attrCtor* RCURLY | COLON );
69+
attrFunc : defFunc | attribBlk ( defFunc | LCURLY attrFunc* RCURLY | COLON );
70+
attrOp : defOp | attribBlk ( defOp | LCURLY attrOp* RCURLY | COLON );
71+
attrVar : defVar | attribBlk ( defVar | LCURLY attrVar* RCURLY | COLON );
72+
73+
//// TODO the 3 kinds of attr each?
74+
//attrUsing : attribBlk? defUsing;
75+
//attrAlias : attribBlk? defAlias;
76+
//attrConvert : attribBlk? defConvert;
77+
//attrCtor : attribBlk? defCtor;
78+
//attrFunc : attribBlk? defFunc;
79+
//attrOp : attribBlk? defOp;
80+
//attrVar : attribBlk? defVar;
81+
82+
defNamespace: id (SCOPE id)*
4683
( SEMI
4784
| COLON
4885
| LCURLY levDecl* RCURLY);
4986
50-
declUsing : typespecsNested SEMI;
51-
declAlias : id tplParams? ASSIGN typespec SEMI; // TODO: needs multiple support
52-
declAspect : id tplParams?; // TODO
53-
declConcept : id tplParams? // TODO
87+
defUsing : typespecsNested;
88+
defAlias : id tplParams? ASSIGN typespec; // TODO: needs COMMA multiple support
89+
90+
defAspect : id tplParams?; // TODO
91+
defConcept : id tplParams? // TODO
5492
(COLON typespecsNested)?
5593
LCURLY levDecl* RCURLY;
56-
declConvert : ( RARROW to=typespec // convert -> TYPE - convert to TYPE - operator TYPE
57-
| from=typespec RARROW id? // convert TYPE -> - convert from TYPE - ctor( TYPE )
58-
| LARROW from=typespec id? // convert <- TYPE - convert from TYPE - ctor( TYPE )
59-
) funcBody;
60-
declCtor : ( DEFAULT
61-
| (COPY|MOVE|FORWARD) id?
62-
| CONVERT LARROW? typespec id?
63-
| CONVERT typespec id? RARROW?
64-
| funcTypeDef? initList?
65-
) funcBody;
66-
declDtor : (LPAREN RPAREN)? funcBody;
67-
declEnum : id
94+
defEnum : id
6895
(COLON bases=typespecBasic)? // TODO: enum inheritance
6996
LCURLY idExprs RCURLY;
70-
71-
declOp : ( (COPY|MOVE) ASSIGN id? funcBody
72-
| CONVERT RARROW? funcBody
73-
| opDef
74-
| LCURLY attrOp* RCURLY);
75-
76-
declFunc : v=( FUNC | PROC | METHOD )
77-
( funcDef
78-
| LCURLY attrFunc* RCURLY);
79-
80-
declStruct : v=( STRUCT | CLASS | UNION )
81-
id tplParams?
97+
defStruct : id tplParams?
8298
(COLON bases=typespecsNested)?
8399
(REQUIRES reqs=typespecsNested)? // TODO
84100
LCURLY levDecl* RCURLY;
85101
86-
declVar : v=( VAR | FIELD | CONST | LET )
87-
( typedIdAcors
88-
| LCURLY attrVar* RCURLY);
102+
defConvert : ( RARROW to=typespec // convert -> TYPE - convert to TYPE - operator TYPE
103+
| from=typespec id? RARROW // convert TYPE -> - convert from TYPE - ctor( TYPE ) // not very analogous to the return type definition
104+
| LARROW from=typespec id? // convert <- TYPE - convert from TYPE - ctor( TYPE )
105+
)
106+
funcBody;
107+
defCtor : ( kindOfPassing id?
108+
| CONVERT LARROW? typespec id?
109+
| CONVERT typespec id? RARROW?
110+
| funcTypeDef? initList?
111+
)
112+
funcBody;
113+
defDtor : (LPAREN RPAREN)?
114+
funcBody;
115+
defFunc : id tplParams? funcTypeDef?
116+
(RARROW typespec)?
117+
(REQUIRES typespecsNested)? // TODO
118+
funcBody;
119+
defOp : ( kindOfPassing ASSIGN id?
120+
| CONVERT RARROW?
121+
| STRING_LIT tplParams? funcTypeDef?
122+
(RARROW typespec)?
123+
(REQUIRES typespecsNested)? // TODO
124+
)
125+
funcBody;
126+
127+
defVar : typedIdAcors;
128+
129+
130+
89131
90-
// TODO the 3 kinds of attr each
91-
attrFunc : attribBlk? funcDef;
92-
attrOp : attribBlk? opDef;
93-
attrVar : attribBlk? typedIdAcors;
94-
*/
95132
/*
96133
opDef : STRING_LIT tplParams? funcTypeDef?
97134
(RARROW typespec)?

backend/backend.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</PropertyGroup>
2020

2121
<ItemGroup>
22-
<PackageReference Include="Antlr4.Runtime.Standard" Version="4.9.3" />
22+
<PackageReference Include="Antlr4.Runtime.Standard" Version="4.10.1" />
2323
</ItemGroup>
2424

2525
<ItemGroup>

frontend/frontend.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
</ItemGroup>
9898

9999
<ItemGroup>
100-
<PackageReference Include="CommandLineParser" Version="2.9.0-preview1" />
100+
<PackageReference Include="CommandLineParser" Version="2.9.1" />
101101
</ItemGroup>
102102

103103
</Project>

frontend/tests/gol/game_of_life.myll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class GameOfLife
1919
[pub]:
2020
ctor()
2121
{
22-
var Map2D& dstMap = doubleBufferedMap[currentIndex];
22+
var Map2D & dstMap = doubleBufferedMap[currentIndex];
2323

2424
do sizeY times y
2525
{
@@ -55,7 +55,7 @@ class GameOfLife
5555
else
5656
{
5757
const bool aliveSelf = srcMap[y][x] == 'o';
58-
const int aliveNB =
58+
const int aliveNeighborCount =
5959
(srcMap[y-1][x-1] == 'o')
6060
+ (srcMap[y-1][x ] == 'o')
6161
+ (srcMap[y-1][x+1] == 'o')
@@ -65,8 +65,8 @@ class GameOfLife
6565
+ (srcMap[y+1][x ] == 'o')
6666
+ (srcMap[y+1][x+1] == 'o');
6767
const bool aliveDst = aliveSelf
68-
? (aliveNB == 2 || aliveNB == 3)
69-
: (aliveNB == 3);
68+
? (aliveNeighborCount == 2 || aliveNeighborCount == 3)
69+
: (aliveNeighborCount == 3);
7070

7171
dstMap[y][x] = aliveDst ? 'o' : ' ';
7272
}

frontend/tests/thesis/main.myll

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,31 +288,36 @@ namespace ctor_fun {
288288
class Test {
289289
field f32 f;
290290
[pub]:
291-
ctor() {}
292-
ctor {} // same as above
293-
ctor default {} // same as above
294-
// ctor( default ) {} // same as above
291+
ctor() {}
292+
ctor {} // same as above
293+
ctor; // defaulted default ctor
295294

296295
[moep]{
296+
method isEmpty() -> bool => _size == 0;
297297
ctor{}
298298
}
299299

300300
ctor( const Test & other ) { f = other.f; }
301301
ctor copy { f = other.f; } // same as above
302-
copy ctor o { f = o.f; } // same as above
302+
ctor copy o { f = o.f; } // same as above
303303

304304
[implicit] ctor( bool b ) { f = b ? 1 : 2; }
305305
ctor convert bool b { f = b ? 1 : 2; } // same as above
306-
convert ctor bool { f = other ? 1 : 2; } // same as above
307-
// ctor convert <- bool { f = other ? 1 : 2; } // same as above
308-
// convert ctor <- bool b { f = b ? 1 : 2; } // same as above
306+
ctor convert bool { f = other ? 1 : 2; } // same as above
307+
ctor convert <- bool { f = other ? 1 : 2; } // same as above
308+
ctor convert bool -> { f = other ? 1 : 2; } // same as above
309+
convert <- bool b { f = b ? 1 : 2; } // same as above
310+
convert bool b -> { f = b ? 1 : 2; } // same as above
309311

310312
dtor() {}
311313
dtor {} // same as above
314+
dtor; // defaulted dtor
312315

313316
operator "=" ( const Test & other ) { f = other.f; }
314-
operator copy "=" { f = other.f; } // same as above
315-
copy operator "=" { f = other.f; } // same as above
317+
operator copy= { f = other.f; } // same as above
318+
319+
operator "=" ( Test && other ) { f = other.f; }
320+
operator move= { f = other.f; } // same as above
316321
// operator "=" copy { f = other.f; } // same as above
317322
}
318323
}

0 commit comments

Comments
 (0)