Skip to content

Commit

Permalink
Fixed issue in Parakeet parse tree generation:
Browse files Browse the repository at this point in the history
  • Loading branch information
cdiggins committed Mar 18, 2024
1 parent b283977 commit 37d605f
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Plato.AST/AstNodeFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static AstNode CreateBinaryOp(ILocation location, string op, AstNode left

return new AstBinaryOp(location, op, left, right);
}

public static AstNode ToAst(this CstExpression expr)
{
var r = ToAst(expr.InnerExpression.Node.LeafExpression.Node);
Expand Down
8 changes: 5 additions & 3 deletions PlatoWinFormsEditor/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Editor
public string LogString => LogBuilder.ToString();
public string AstString { get; }
public string TokensString { get; }
public string ParseNodesString { get; }
public string ParseTreeString { get; }
public string CstString { get; }
public string ErrorsString { get; }
Expand Down Expand Up @@ -63,15 +64,16 @@ public Editor(FilePath filePath,

Logger.Log($"Tokenization");
Tokenizer = CommonParsers.PlatoTokenizer(Input, Logger);
TokensString = Tokenizer.ParserNodes.JoinStrings(Environment.NewLine);
TokensString = Tokenizer.ParserNodesString;

Logger.Log("Applying styles");
ApplyStyles();

Logger.Log($"Parsing");
Parser = CommonParsers.PlatoParser(Input, Logger);
CstString = Parser.CstXml;
ParseNodesString = Parser.ParserNodesString;
ParseTreeString = Parser.ParseXml;
CstString = Parser.CstXml;
ErrorsString = Parser.ErrorMessages.JoinStrings(Environment.NewLine);

Logger.Log($"Highlighting Errors");
Expand Down Expand Up @@ -100,7 +102,7 @@ public void OnLogMessage(string logMsg)

public void ApplyStyle(string kind, ParserRange range)
{

ApplyStyle(kind, range.BeginPosition, range.EndPosition);
}

public void ApplyStyle(string kind, int start, int length)
Expand Down
101 changes: 78 additions & 23 deletions PlatoWinFormsEditor/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions PlatoWinFormsEditor/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public Form1()
AddHandlers(richTextBoxLog);
AddHandlers(richTextBoxConsole);
AddHandlers(richTextBoxTokens);
AddHandlers(richTextBoxParseTree);
AddHandlers(richTextBoxNodes);
AddHandlers(richTextBoxAst);
AddHandlers(richTextBoxCst);
AddHandlers(richTextBoxErrors);
Expand Down Expand Up @@ -145,6 +147,8 @@ private void EditorChanged(Editor? editor)
richTextBoxCst.Text = editor?.CstString ?? "";
richTextBoxErrors.Text = editor?.ErrorsString ?? "";
richTextBoxTokens.Text = editor?.TokensString ?? "";
richTextBoxParseTree.Text = editor?.ParseTreeString ?? "";
richTextBoxNodes.Text = editor?.ParseNodesString ?? "";
}

public void OnLogMsg(string msg)
Expand Down

0 comments on commit 37d605f

Please sign in to comment.