Skip to content

Commit 1ea8750

Browse files
committed
Starting work on 1.4.4. Plato now reports errors better.
1 parent a00781a commit 1ea8750

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1217
-1467
lines changed

Parakeet.Cst/CSharpGrammarCst.cs

+144-174
Large diffs are not rendered by default.

Parakeet.Cst/CSharpGrammarCstFactory.cs

+144-151
Large diffs are not rendered by default.

Parakeet.Cst/CombinatorCalculusGrammarCst.cs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// DO NOT EDIT: Autogenerated file created on 2024-03-19 2:18:53 PM.
1+
// DO NOT EDIT: Autogenerated file created on 2024-03-19 10:22:19 PM.
22
using System;
33
using System.Linq;
44

@@ -14,7 +14,7 @@ public interface ICombinatorCalculusCstNode { }
1414
public class CstApplication : CstNodeSequence, ICombinatorCalculusCstNode
1515
{
1616
public static Rule Rule = CstNodeFactory.StaticGrammar.Application;
17-
public CstApplication(params CstNode[] children) : base(children) { }
17+
public CstApplication(ILocation location, params CstNode[] children) : base(location, children) { }
1818
public CstNodeFilter<CstTerm> Term => new CstNodeFilter<CstTerm> (Children);
1919
}
2020

@@ -25,8 +25,7 @@ public CstApplication(params CstNode[] children) : base(children) { }
2525
public class CstCombinator : CstNodeLeaf, ICombinatorCalculusCstNode
2626
{
2727
public static Rule Rule = CstNodeFactory.StaticGrammar.Combinator;
28-
public CstCombinator(string text) : base(text) { }
29-
// No children
28+
public CstCombinator(ILocation location, string text) : base(location, text) { }
3029
}
3130

3231
/// <summary>
@@ -36,8 +35,7 @@ public CstCombinator(string text) : base(text) { }
3635
public class CstIdentifier : CstNodeLeaf, ICombinatorCalculusCstNode
3736
{
3837
public static Rule Rule = CstNodeFactory.StaticGrammar.Identifier;
39-
public CstIdentifier(string text) : base(text) { }
40-
// No children
38+
public CstIdentifier(ILocation location, string text) : base(location, text) { }
4139
}
4240

4341
/// <summary>
@@ -47,7 +45,7 @@ public CstIdentifier(string text) : base(text) { }
4745
public class CstTerm : CstNodeChoice, ICombinatorCalculusCstNode
4846
{
4947
public static Rule Rule = CstNodeFactory.StaticGrammar.Term;
50-
public CstTerm(params CstNode[] children) : base(children) { }
48+
public CstTerm(ILocation location, params CstNode[] children) : base(location, children) { }
5149
public CstNodeFilter<CstTerm> Term => new CstNodeFilter<CstTerm> (Children);
5250
public CstNodeFilter<CstApplication> Application => new CstNodeFilter<CstApplication> (Children);
5351
public CstNodeFilter<CstCombinator> Combinator => new CstNodeFilter<CstCombinator> (Children);

Parakeet.Cst/CombinatorCalculusGrammarCstFactory.cs

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// DO NOT EDIT: Autogenerated file created on 2024-03-19 2:18:53 PM.
1+
// DO NOT EDIT: Autogenerated file created on 2024-03-19 10:22:19 PM.
22
using System;
33
using System.Linq;
44
using System.Collections.Generic;
@@ -10,21 +10,14 @@ public class CstNodeFactory : INodeFactory
1010
{
1111
public static CombinatorCalculusGrammar StaticGrammar = CombinatorCalculusGrammar.Instance;
1212
public IGrammar Grammar { get; } = StaticGrammar;
13-
public Dictionary<CstNode, ParserTreeNode> Lookup { get;} = new Dictionary<CstNode, ParserTreeNode>();
1413
public CstNode Create(ParserTreeNode node)
15-
{
16-
var r = InternalCreate(node);
17-
Lookup.Add(r, node);
18-
return r;
19-
}
20-
public CstNode InternalCreate(ParserTreeNode node)
2114
{
2215
switch (node.Type)
2316
{
24-
case "Application": return new CstApplication(node.Children.Select(Create).ToArray());
25-
case "Combinator": return new CstCombinator(node.Contents);
26-
case "Identifier": return new CstIdentifier(node.Contents);
27-
case "Term": return new CstTerm(node.Children.Select(Create).ToArray());
17+
case "Application": return new CstApplication(node, node.Children.Select(Create).ToArray());
18+
case "Combinator": return new CstCombinator(node, node.Contents);
19+
case "Identifier": return new CstIdentifier(node, node.Contents);
20+
case "Term": return new CstTerm(node, node.Children.Select(Create).ToArray());
2821
default: throw new Exception($"Unrecognized parse node {node.Type}");
2922
}
3023
}

Parakeet.Cst/CssGrammarCst.cs

+36-50
Large diffs are not rendered by default.

Parakeet.Cst/CssGrammarCstFactory.cs

+36-43
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// DO NOT EDIT: Autogenerated file created on 2024-03-19 2:18:54 PM.
1+
// DO NOT EDIT: Autogenerated file created on 2024-03-19 10:22:21 PM.
22
using System;
33
using System.Linq;
44
using System.Collections.Generic;
@@ -10,52 +10,45 @@ public class CstNodeFactory : INodeFactory
1010
{
1111
public static CssGrammar StaticGrammar = CssGrammar.Instance;
1212
public IGrammar Grammar { get; } = StaticGrammar;
13-
public Dictionary<CstNode, ParserTreeNode> Lookup { get;} = new Dictionary<CstNode, ParserTreeNode>();
1413
public CstNode Create(ParserTreeNode node)
15-
{
16-
var r = InternalCreate(node);
17-
Lookup.Add(r, node);
18-
return r;
19-
}
20-
public CstNode InternalCreate(ParserTreeNode node)
2114
{
2215
switch (node.Type)
2316
{
24-
case "Attrib": return new CstAttrib(node.Children.Select(Create).ToArray());
25-
case "AttribOperator": return new CstAttribOperator(node.Contents);
26-
case "AttribValue": return new CstAttribValue(node.Contents);
27-
case "CharSet": return new CstCharSet(node.Contents);
28-
case "Class": return new CstClass(node.Contents);
29-
case "Combinator": return new CstCombinator(node.Contents);
30-
case "CombinedSelector": return new CstCombinedSelector(node.Children.Select(Create).ToArray());
31-
case "Content": return new CstContent(node.Children.Select(Create).ToArray());
32-
case "Contents": return new CstContents(node.Children.Select(Create).ToArray());
33-
case "Declaration": return new CstDeclaration(node.Children.Select(Create).ToArray());
34-
case "Declarations": return new CstDeclarations(node.Children.Select(Create).ToArray());
35-
case "ElementName": return new CstElementName(node.Contents);
36-
case "Expr": return new CstExpr(node.Children.Select(Create).ToArray());
37-
case "Function": return new CstFunction(node.Children.Select(Create).ToArray());
38-
case "HexColor": return new CstHexColor(node.Contents);
39-
case "Identifier": return new CstIdentifier(node.Contents);
40-
case "Import": return new CstImport(node.Children.Select(Create).ToArray());
41-
case "Imports": return new CstImports(node.Children.Select(Create).ToArray());
42-
case "MediaList": return new CstMediaList(node.Children.Select(Create).ToArray());
43-
case "Medium": return new CstMedium(node.Contents);
44-
case "Operator": return new CstOperator(node.Contents);
45-
case "Page": return new CstPage(node.Children.Select(Create).ToArray());
46-
case "PageDeclarations": return new CstPageDeclarations(node.Children.Select(Create).ToArray());
47-
case "Prio": return new CstPrio(node.Contents);
48-
case "Property": return new CstProperty(node.Contents);
49-
case "Pseudo": return new CstPseudo(node.Children.Select(Create).ToArray());
50-
case "PseudoPage": return new CstPseudoPage(node.Contents);
51-
case "RuleSet": return new CstRuleSet(node.Children.Select(Create).ToArray());
52-
case "Selector": return new CstSelector(node.Children.Select(Create).ToArray());
53-
case "SelectorPart": return new CstSelectorPart(node.Children.Select(Create).ToArray());
54-
case "Selectors": return new CstSelectors(node.Children.Select(Create).ToArray());
55-
case "SimpleSelector": return new CstSimpleSelector(node.Children.Select(Create).ToArray());
56-
case "StyleSheet": return new CstStyleSheet(node.Children.Select(Create).ToArray());
57-
case "Term": return new CstTerm(node.Children.Select(Create).ToArray());
58-
case "UnaryOperator": return new CstUnaryOperator(node.Contents);
17+
case "Attrib": return new CstAttrib(node, node.Children.Select(Create).ToArray());
18+
case "AttribOperator": return new CstAttribOperator(node, node.Contents);
19+
case "AttribValue": return new CstAttribValue(node, node.Contents);
20+
case "CharSet": return new CstCharSet(node, node.Contents);
21+
case "Class": return new CstClass(node, node.Contents);
22+
case "Combinator": return new CstCombinator(node, node.Contents);
23+
case "CombinedSelector": return new CstCombinedSelector(node, node.Children.Select(Create).ToArray());
24+
case "Content": return new CstContent(node, node.Children.Select(Create).ToArray());
25+
case "Contents": return new CstContents(node, node.Children.Select(Create).ToArray());
26+
case "Declaration": return new CstDeclaration(node, node.Children.Select(Create).ToArray());
27+
case "Declarations": return new CstDeclarations(node, node.Children.Select(Create).ToArray());
28+
case "ElementName": return new CstElementName(node, node.Contents);
29+
case "Expr": return new CstExpr(node, node.Children.Select(Create).ToArray());
30+
case "Function": return new CstFunction(node, node.Children.Select(Create).ToArray());
31+
case "HexColor": return new CstHexColor(node, node.Contents);
32+
case "Identifier": return new CstIdentifier(node, node.Contents);
33+
case "Import": return new CstImport(node, node.Children.Select(Create).ToArray());
34+
case "Imports": return new CstImports(node, node.Children.Select(Create).ToArray());
35+
case "MediaList": return new CstMediaList(node, node.Children.Select(Create).ToArray());
36+
case "Medium": return new CstMedium(node, node.Contents);
37+
case "Operator": return new CstOperator(node, node.Contents);
38+
case "Page": return new CstPage(node, node.Children.Select(Create).ToArray());
39+
case "PageDeclarations": return new CstPageDeclarations(node, node.Children.Select(Create).ToArray());
40+
case "Prio": return new CstPrio(node, node.Contents);
41+
case "Property": return new CstProperty(node, node.Contents);
42+
case "Pseudo": return new CstPseudo(node, node.Children.Select(Create).ToArray());
43+
case "PseudoPage": return new CstPseudoPage(node, node.Contents);
44+
case "RuleSet": return new CstRuleSet(node, node.Children.Select(Create).ToArray());
45+
case "Selector": return new CstSelector(node, node.Children.Select(Create).ToArray());
46+
case "SelectorPart": return new CstSelectorPart(node, node.Children.Select(Create).ToArray());
47+
case "Selectors": return new CstSelectors(node, node.Children.Select(Create).ToArray());
48+
case "SimpleSelector": return new CstSimpleSelector(node, node.Children.Select(Create).ToArray());
49+
case "StyleSheet": return new CstStyleSheet(node, node.Children.Select(Create).ToArray());
50+
case "Term": return new CstTerm(node, node.Children.Select(Create).ToArray());
51+
case "UnaryOperator": return new CstUnaryOperator(node, node.Contents);
5952
default: throw new Exception($"Unrecognized parse node {node.Type}");
6053
}
6154
}

Parakeet.Cst/CsvGrammarCst.cs

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// DO NOT EDIT: Autogenerated file created on 2024-03-19 2:18:54 PM.
1+
// DO NOT EDIT: Autogenerated file created on 2024-03-19 10:22:21 PM.
22
using System;
33
using System.Linq;
44

@@ -14,7 +14,7 @@ public interface ICsvCstNode { }
1414
public class CstField : CstNodeChoice, ICsvCstNode
1515
{
1616
public static Rule Rule = CstNodeFactory.StaticGrammar.Field;
17-
public CstField(params CstNode[] children) : base(children) { }
17+
public CstField(ILocation location, params CstNode[] children) : base(location, children) { }
1818
public CstNodeFilter<CstText> Text => new CstNodeFilter<CstText> (Children);
1919
public CstNodeFilter<CstString> String => new CstNodeFilter<CstString> (Children);
2020
}
@@ -26,7 +26,7 @@ public CstField(params CstNode[] children) : base(children) { }
2626
public class CstFile : CstNode, ICsvCstNode
2727
{
2828
public static Rule Rule = CstNodeFactory.StaticGrammar.File;
29-
public CstFile(params CstNode[] children) : base(children) { }
29+
public CstFile(ILocation location, params CstNode[] children) : base(location, children) { }
3030
public CstNodeFilter<CstRow> Row => new CstNodeFilter<CstRow> (Children);
3131
}
3232

@@ -37,8 +37,7 @@ public CstFile(params CstNode[] children) : base(children) { }
3737
public class CstIdentifier : CstNodeLeaf, ICsvCstNode
3838
{
3939
public static Rule Rule = CstNodeFactory.StaticGrammar.Identifier;
40-
public CstIdentifier(string text) : base(text) { }
41-
// No children
40+
public CstIdentifier(ILocation location, string text) : base(location, text) { }
4241
}
4342

4443
/// <summary>
@@ -48,7 +47,7 @@ public CstIdentifier(string text) : base(text) { }
4847
public class CstRow : CstNode, ICsvCstNode
4948
{
5049
public static Rule Rule = CstNodeFactory.StaticGrammar.Row;
51-
public CstRow(params CstNode[] children) : base(children) { }
50+
public CstRow(ILocation location, params CstNode[] children) : base(location, children) { }
5251
public CstNodeFilter<CstField> Field => new CstNodeFilter<CstField> (Children);
5352
}
5453

@@ -59,8 +58,7 @@ public CstRow(params CstNode[] children) : base(children) { }
5958
public class CstString : CstNodeLeaf, ICsvCstNode
6059
{
6160
public static Rule Rule = CstNodeFactory.StaticGrammar.String;
62-
public CstString(string text) : base(text) { }
63-
// No children
61+
public CstString(ILocation location, string text) : base(location, text) { }
6462
}
6563

6664
/// <summary>
@@ -70,8 +68,7 @@ public CstString(string text) : base(text) { }
7068
public class CstText : CstNodeLeaf, ICsvCstNode
7169
{
7270
public static Rule Rule = CstNodeFactory.StaticGrammar.Text;
73-
public CstText(string text) : base(text) { }
74-
// No children
71+
public CstText(ILocation location, string text) : base(location, text) { }
7572
}
7673

7774
}

Parakeet.Cst/CsvGrammarCstFactory.cs

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// DO NOT EDIT: Autogenerated file created on 2024-03-19 2:18:54 PM.
1+
// DO NOT EDIT: Autogenerated file created on 2024-03-19 10:22:21 PM.
22
using System;
33
using System.Linq;
44
using System.Collections.Generic;
@@ -10,23 +10,16 @@ public class CstNodeFactory : INodeFactory
1010
{
1111
public static CsvGrammar StaticGrammar = CsvGrammar.Instance;
1212
public IGrammar Grammar { get; } = StaticGrammar;
13-
public Dictionary<CstNode, ParserTreeNode> Lookup { get;} = new Dictionary<CstNode, ParserTreeNode>();
1413
public CstNode Create(ParserTreeNode node)
15-
{
16-
var r = InternalCreate(node);
17-
Lookup.Add(r, node);
18-
return r;
19-
}
20-
public CstNode InternalCreate(ParserTreeNode node)
2114
{
2215
switch (node.Type)
2316
{
24-
case "Field": return new CstField(node.Children.Select(Create).ToArray());
25-
case "File": return new CstFile(node.Children.Select(Create).ToArray());
26-
case "Identifier": return new CstIdentifier(node.Contents);
27-
case "Row": return new CstRow(node.Children.Select(Create).ToArray());
28-
case "String": return new CstString(node.Contents);
29-
case "Text": return new CstText(node.Contents);
17+
case "Field": return new CstField(node, node.Children.Select(Create).ToArray());
18+
case "File": return new CstFile(node, node.Children.Select(Create).ToArray());
19+
case "Identifier": return new CstIdentifier(node, node.Contents);
20+
case "Row": return new CstRow(node, node.Children.Select(Create).ToArray());
21+
case "String": return new CstString(node, node.Contents);
22+
case "Text": return new CstText(node, node.Contents);
3023
default: throw new Exception($"Unrecognized parse node {node.Type}");
3124
}
3225
}

0 commit comments

Comments
 (0)