-
Notifications
You must be signed in to change notification settings - Fork 0
Brought back the compiler with a new API #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThis update removes the entire PiccodeScript language parsing, runtime, and AST infrastructure, including all ANTLR grammar, parser, and lexer files, as well as all Java code for AST nodes, runtime value types, modules, and native function modules. It also deletes all standard library Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant EditorWindow
participant CanvasFrame
participant Compiler (external)
participant AccessFrameOutputStream
User->>EditorWindow: Triggers compile or render action
EditorWindow->>CanvasFrame: Sets file, code, start=true
CanvasFrame->>CanvasFrame: paintComponent() detects start==true
CanvasFrame->>CanvasFrame: Schedules compileFrame() on new thread
CanvasFrame->>Compiler: compile(file, code)
Compiler-->>CanvasFrame: Compilation result
Compiler->>AccessFrameOutputStream: Writes output/logs
CanvasFrame->>CanvasFrame: Resets start=false
Estimated code review effort🎯 5 (Critical) | ⏱️ ~90+ minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 22
🔭 Outside diff range comments (1)
src/main/java/org/editor/errors/EditorParser.java (1)
22-54: Critical functionality regression: Syntax error detection completely disabled.The
parsemethod now returns an empty result without performing any syntax analysis. This means:
- No syntax error highlighting in the editor
- No real-time feedback for developers
- Poor developer experience compared to before
The commented-out ANTLR code suggests this is temporary, but shipping without syntax error detection is a significant regression.
Consider one of these approaches:
- Implement new parsing logic to replace the removed ANTLR infrastructure
- Add a TODO comment explaining the temporary nature and timeline for restoration
- Add logging to indicate parsing is disabled
public ParseResult parse(RSyntaxDocument doc, String style) { DefaultParseResult result = new DefaultParseResult(this); + // TODO: Syntax parsing temporarily disabled due to ANTLR removal + // Need to implement new parsing logic for error detection try { String code = doc.getText(0, doc.getLength()); } catch (BadLocationException ex) { System.getLogger(EditorParser.class.getName()).log(System.Logger.Level.ERROR, (String) null, ex); }
🧹 Nitpick comments (16)
src/main/java/org/editor/events/MenuEvents.java (1)
136-139: Consider future implementation and method visibility.The current implementation correctly delegates to
EditorWindow.addTab(e)to create a new editor tab. The TODO comment indicates plans for a file creator dialog.Two considerations:
- Would you like me to help design the file creator dialog mentioned in the TODO?
- Consider making this method
publicfor consistency with other event handler methods in this class likegotoLineEvent,aboutDialog,closeTab, etc.src/main/java/org/editor/CodeEditor.java (1)
136-143: Consider refactoring to reduce code duplication.The method correctly creates and configures a new
DockKey, but duplicates logic from the constructor (lines 105-120).Consider extracting the common DockKey creation logic into a private helper method:
+ private DockKey createDockKey(String name) { + String tip = "Source code editor"; + var icon = Icons.getIcon("code-file"); + var key = new DockKey(name, name, tip, icon); + key.setCloseEnabled(true); + key.setAutoHideEnabled(true); + return key; + } + public void setKey(String name) { - String tip = "Source code editor"; - var icon = Icons.getIcon("code-file"); - key = new DockKey(name, name, tip, icon); - key.setCloseEnabled(true); - key.setAutoHideEnabled(true); + key = createDockKey(name); this.putClientProperty("dockKey", key); }Then update the constructor to use the same helper method.
examples/factorial.pics (1)
8-12: Address variable name reuse and consider large computation implications.Two issues to consider:
Variable name reuse: The variable
resultis declared twice (lines 8 and 11). Depending on the language's scoping rules, this may cause shadowing or redeclaration issues.Large computation:
factorial(100)produces an extremely large number (9.33 × 10^157). Ensure the runtime can handle such large integers without overflow or performance issues.Consider using different variable names and potentially adding a comment about the large number:
let result = factorial(5) IO.println(result) -let result = factorial(100) -IO.println(result) +let large_result = factorial(100) // Very large number: ~9.33 × 10^157 +IO.println(large_result)src/main/java/org/editor/panels/PluginsPanel.java (1)
9-17: LGTM! Clean foundation for plugins panel.The class structure follows the established pattern for dockable panels with appropriate parameters (title, tooltip, icon). The TODO comment clearly indicates future implementation is needed.
When you're ready to implement the plugins functionality, I can help design the UI components and plugin management logic.
src/main/java/org/editor/panels/VCPanel.java (1)
9-17: LGTM! Consistent pattern for version control panel.The class follows the established dockable panel pattern with Git-focused parameters (title, tooltip, icon). The TODO comment appropriately indicates future implementation is needed.
When implementing the version control features, I can help design Git integration components and workflow UI elements.
examples/arrays.pics (1)
12-12: Fix typo in variable name.The variable name has a spelling error.
-let collon_sep = Array.join(strings, ":") +let colon_sep = Array.join(strings, ":")examples/showcase.pics (1)
19-21: Potential variable shadowing issue.The variable
numbersis redefined from an array to a tuple, which might confuse readers about variable scoping and shadowing behavior.Consider using different variable names to avoid confusion:
// Arrays let numbers = [1,2,3] let first = numbers.0 let joined = first:numbers // Tuples -let numbers = (1,2,3) -let first = numbers.0 +let tuple_nums = (1,2,3) +let tuple_first = tuple_nums.0pkg/math/math.pics (2)
32-33: Consider using a constant for PI value.The hardcoded PI value
3.141592653589793is duplicated betweendegToRadandradToDegfunctions. Consider defining a module-level constant for better maintainability.+ const PI = 3.141592653589793 + - function degToRad(deg=0) = deg * (3.141592653589793 / 180) - function radToDeg(rad=0) = rad * (180 / 3.141592653589793) + function degToRad(deg=0) = deg * (PI / 180) + function radToDeg(rad=0) = rad * (180 / PI)
35-36: Potential duplication with Number module.The
isEvenandisOddfunctions here duplicate the same functionality provided in theNumbermodule. Consider whether these belong in both modules or if there should be a single canonical location.pkg/number/number.pics (1)
6-7: Duplication between Math and Number modules.The
isEvenandisOddfunctions are duplicated between this module and theMathmodule. Consider establishing a clear separation of concerns - typically, basic numeric predicates belong in aNumbermodule while mathematical functions belong inMath.Also applies to: 35-36
src/main/java/org/editor/panels/FileTreePanel.java (2)
38-38: Fix typo in error message.There's a typo in the error message: "extit" should be "exist".
- System.err.println("error: " + file + " does not extit"); + System.err.println("error: " + file + " does not exist");
30-30: Consider performance implications for large directory structures.Loading the entire directory tree synchronously from the current working directory could cause UI blocking for large projects. Consider implementing lazy loading where subdirectories are loaded only when expanded.
Also applies to: 46-52
src/main/java/org/editor/AccessFrame.java (2)
224-248: Consider extending ANSI escape code support.The current implementation only supports foreground colors. For more complete terminal emulation, consider supporting:
- Background colors (40-47, 100-107)
- Text styles (1=bold, 3=italic, 4=underline)
- Proper reset handling for individual attributes
Would you like me to provide an enhanced implementation that supports these additional ANSI features?
150-150: Consider making the PrintStream configurableThe static
PrintStream outis hardcoded. Consider making it configurable or providing a factory method for better testability.- public static final PrintStream out = new PrintStream(new AccessFrameOutputStream(), true, StandardCharsets.UTF_8); + private static PrintStream out = new PrintStream(new AccessFrameOutputStream(), true, StandardCharsets.UTF_8); + + public static PrintStream getOutputStream() { + return out; + } + + public static void setOutputStream(PrintStream stream) { + out = stream; + }src/main/java/org/editor/CanvasFrame.java (1)
28-35: Remove unused importsThese imports appear to be unused after the refactoring and should be removed:
org.piccode.ast.Astorg.piccode.rt.Contextorg.piccode.rt.PiccodeExceptionorg.piccode.rt.PiccodeNumberorg.piccode.rt.PiccodeReturnExceptionorg.piccode.rt.PiccodeUnitorg.piccode.rt.PiccodeValuesrc/main/java/org/editor/EditorWindow.java (1)
430-430: Fix typo in method nameThe method name has a typo: "setSeletedTabTitle" should be "setSelectedTabTitle".
- public static void setSeletedTabTitle(String title) { + public static void setSelectedTabTitle(String title) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
src/main/resources/icons/markdown.pngis excluded by!**/*.png
📒 Files selected for processing (89)
examples/arrays.pics(1 hunks)examples/factorial.pics(1 hunks)examples/hello.pics(1 hunks)examples/showcase.pics(1 hunks)pkg/array/array.pics(1 hunks)pkg/math/math.pics(1 hunks)pkg/number/number.pics(1 hunks)pkg/string/string.pics(1 hunks)pkg/tuple/tuple.pics(1 hunks)pom.xml(2 hunks)src/main/antlr4/PiccodeScript.g4(0 hunks)src/main/java/org/editor/AccessFrame.java(8 hunks)src/main/java/org/editor/CanvasFrame.java(5 hunks)src/main/java/org/editor/CodeEditor.java(1 hunks)src/main/java/org/editor/EditorWindow.java(7 hunks)src/main/java/org/editor/errors/EditorParser.java(3 hunks)src/main/java/org/editor/errors/IDEErrorListener.java(0 hunks)src/main/java/org/editor/events/AccessEvents.java(2 hunks)src/main/java/org/editor/events/Actions.java(1 hunks)src/main/java/org/editor/events/MenuEvents.java(1 hunks)src/main/java/org/editor/icons/Icons.java(1 hunks)src/main/java/org/editor/panels/FileTreePanel.java(1 hunks)src/main/java/org/editor/panels/PluginsPanel.java(1 hunks)src/main/java/org/editor/panels/VCPanel.java(1 hunks)src/main/java/org/piccode/antlr4/PiccodeScript.interp(0 hunks)src/main/java/org/piccode/antlr4/PiccodeScript.tokens(0 hunks)src/main/java/org/piccode/antlr4/PiccodeScriptBaseListener.java(0 hunks)src/main/java/org/piccode/antlr4/PiccodeScriptBaseVisitor.java(0 hunks)src/main/java/org/piccode/antlr4/PiccodeScriptLexer.interp(0 hunks)src/main/java/org/piccode/antlr4/PiccodeScriptLexer.java(0 hunks)src/main/java/org/piccode/antlr4/PiccodeScriptLexer.tokens(0 hunks)src/main/java/org/piccode/antlr4/PiccodeScriptListener.java(0 hunks)src/main/java/org/piccode/antlr4/PiccodeScriptParser.java(0 hunks)src/main/java/org/piccode/antlr4/PiccodeScriptVisitor.java(0 hunks)src/main/java/org/piccode/ast/Arg.java(0 hunks)src/main/java/org/piccode/ast/ArrayAst.java(0 hunks)src/main/java/org/piccode/ast/Ast.java(0 hunks)src/main/java/org/piccode/ast/BinOpAst.java(0 hunks)src/main/java/org/piccode/ast/CallAst.java(0 hunks)src/main/java/org/piccode/ast/ClosureAst.java(0 hunks)src/main/java/org/piccode/ast/DoExprAst.java(0 hunks)src/main/java/org/piccode/ast/DotOperationAst.java(0 hunks)src/main/java/org/piccode/ast/FunctionAst.java(0 hunks)src/main/java/org/piccode/ast/IdentifierAst.java(0 hunks)src/main/java/org/piccode/ast/IfExpression.java(0 hunks)src/main/java/org/piccode/ast/ImportAst.java(0 hunks)src/main/java/org/piccode/ast/ListConstAst.java(0 hunks)src/main/java/org/piccode/ast/ModuleAst.java(0 hunks)src/main/java/org/piccode/ast/NamedCallArg.java(0 hunks)src/main/java/org/piccode/ast/NumberAst.java(0 hunks)src/main/java/org/piccode/ast/ObjectAst.java(0 hunks)src/main/java/org/piccode/ast/PiccodeVisitor.java(0 hunks)src/main/java/org/piccode/ast/PipeAst.java(0 hunks)src/main/java/org/piccode/ast/StatementList.java(0 hunks)src/main/java/org/piccode/ast/StringAst.java(0 hunks)src/main/java/org/piccode/ast/TupleAst.java(0 hunks)src/main/java/org/piccode/ast/UnaryAst.java(0 hunks)src/main/java/org/piccode/ast/UnitAst.java(0 hunks)src/main/java/org/piccode/ast/VarDecl.java(0 hunks)src/main/java/org/piccode/ast/WhenAst.java(0 hunks)src/main/java/org/piccode/ast/WhenCase.java(0 hunks)src/main/java/org/piccode/backend/Compiler.java(0 hunks)src/main/java/org/piccode/piccode/Piccode.java(1 hunks)src/main/java/org/piccode/rt/Context.java(0 hunks)src/main/java/org/piccode/rt/Evaluator.java(0 hunks)src/main/java/org/piccode/rt/NativeFunction.java(0 hunks)src/main/java/org/piccode/rt/PiccodeArray.java(0 hunks)src/main/java/org/piccode/rt/PiccodeBoolean.java(0 hunks)src/main/java/org/piccode/rt/PiccodeClosure.java(0 hunks)src/main/java/org/piccode/rt/PiccodeException.java(0 hunks)src/main/java/org/piccode/rt/PiccodeModule.java(0 hunks)src/main/java/org/piccode/rt/PiccodeNumber.java(0 hunks)src/main/java/org/piccode/rt/PiccodeObject.java(0 hunks)src/main/java/org/piccode/rt/PiccodeString.java(0 hunks)src/main/java/org/piccode/rt/PiccodeTuple.java(0 hunks)src/main/java/org/piccode/rt/PiccodeUnit.java(0 hunks)src/main/java/org/piccode/rt/PiccodeValue.java(0 hunks)src/main/java/org/piccode/rt/modules/NativeFunctionFactory.java(0 hunks)src/main/java/org/piccode/rt/modules/PiccodeArrayModule.java(0 hunks)src/main/java/org/piccode/rt/modules/PiccodeColorModule.java(0 hunks)src/main/java/org/piccode/rt/modules/PiccodeGfxModule.java(0 hunks)src/main/java/org/piccode/rt/modules/PiccodeIOModule.java(0 hunks)src/main/java/org/piccode/rt/modules/PiccodeMathModule.java(0 hunks)src/main/java/org/piccode/rt/modules/PiccodeResourceModule.java(0 hunks)src/main/java/org/piccode/rt/modules/PiccodeStringModule.java(0 hunks)src/main/java/org/piccode/rt/modules/PiccodeTupleModule.java(0 hunks)src/main/java/org/piccode/tokenmaker/PiccodeScriptTokenMaker.java(4 hunks)src/test/java/org/piccode/ast/TopLevel.java(0 hunks)src/test/java/org/piccode/rt/Runtime.java(0 hunks)
💤 Files with no reviewable changes (65)
- src/main/java/org/piccode/rt/PiccodeValue.java
- src/main/java/org/piccode/ast/Ast.java
- src/main/java/org/piccode/rt/modules/PiccodeTupleModule.java
- src/main/java/org/piccode/ast/UnitAst.java
- src/main/java/org/piccode/ast/Arg.java
- src/main/java/org/piccode/rt/PiccodeException.java
- src/main/java/org/piccode/rt/Evaluator.java
- src/main/java/org/piccode/rt/PiccodeString.java
- src/main/java/org/piccode/antlr4/PiccodeScript.tokens
- src/main/java/org/piccode/ast/ObjectAst.java
- src/main/java/org/piccode/ast/VarDecl.java
- src/main/java/org/piccode/rt/modules/PiccodeResourceModule.java
- src/main/java/org/piccode/ast/TupleAst.java
- src/main/java/org/piccode/antlr4/PiccodeScriptBaseListener.java
- src/main/java/org/piccode/ast/WhenCase.java
- src/main/java/org/piccode/rt/modules/PiccodeStringModule.java
- src/main/java/org/piccode/rt/modules/PiccodeArrayModule.java
- src/main/java/org/piccode/ast/NumberAst.java
- src/main/java/org/piccode/ast/IdentifierAst.java
- src/main/java/org/piccode/antlr4/PiccodeScriptListener.java
- src/main/java/org/piccode/ast/StringAst.java
- src/main/java/org/piccode/ast/PipeAst.java
- src/main/java/org/piccode/rt/modules/PiccodeGfxModule.java
- src/main/java/org/piccode/ast/DoExprAst.java
- src/main/java/org/piccode/ast/StatementList.java
- src/main/java/org/piccode/rt/modules/PiccodeColorModule.java
- src/main/antlr4/PiccodeScript.g4
- src/main/java/org/piccode/ast/ClosureAst.java
- src/main/java/org/piccode/rt/modules/PiccodeMathModule.java
- src/main/java/org/piccode/antlr4/PiccodeScriptBaseVisitor.java
- src/main/java/org/piccode/antlr4/PiccodeScriptVisitor.java
- src/main/java/org/piccode/rt/PiccodeTuple.java
- src/main/java/org/piccode/ast/ModuleAst.java
- src/main/java/org/piccode/ast/FunctionAst.java
- src/main/java/org/piccode/ast/ArrayAst.java
- src/main/java/org/piccode/ast/UnaryAst.java
- src/main/java/org/piccode/rt/PiccodeModule.java
- src/main/java/org/piccode/rt/PiccodeBoolean.java
- src/main/java/org/piccode/ast/NamedCallArg.java
- src/main/java/org/piccode/antlr4/PiccodeScriptLexer.tokens
- src/main/java/org/piccode/ast/ListConstAst.java
- src/main/java/org/piccode/backend/Compiler.java
- src/main/java/org/piccode/rt/PiccodeNumber.java
- src/main/java/org/piccode/ast/CallAst.java
- src/main/java/org/piccode/rt/modules/NativeFunctionFactory.java
- src/main/java/org/piccode/rt/PiccodeArray.java
- src/main/java/org/piccode/ast/BinOpAst.java
- src/main/java/org/piccode/rt/PiccodeUnit.java
- src/main/java/org/piccode/ast/IfExpression.java
- src/main/java/org/piccode/rt/PiccodeClosure.java
- src/test/java/org/piccode/ast/TopLevel.java
- src/main/java/org/piccode/rt/modules/PiccodeIOModule.java
- src/main/java/org/editor/errors/IDEErrorListener.java
- src/main/java/org/piccode/ast/ImportAst.java
- src/main/java/org/piccode/rt/PiccodeObject.java
- src/test/java/org/piccode/rt/Runtime.java
- src/main/java/org/piccode/rt/Context.java
- src/main/java/org/piccode/rt/NativeFunction.java
- src/main/java/org/piccode/antlr4/PiccodeScript.interp
- src/main/java/org/piccode/ast/PiccodeVisitor.java
- src/main/java/org/piccode/ast/WhenAst.java
- src/main/java/org/piccode/ast/DotOperationAst.java
- src/main/java/org/piccode/antlr4/PiccodeScriptLexer.java
- src/main/java/org/piccode/antlr4/PiccodeScriptLexer.interp
- src/main/java/org/piccode/antlr4/PiccodeScriptParser.java
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: the vldocking library (com.vlsolutions.swing.docking) has a distinct component management model wher...
Learnt from: hexaredecimal
PR: Glimmr-Lang/PicassoCode#1
File: src/main/java/org/editor/EditorWindow.java:204-209
Timestamp: 2025-05-14T10:49:23.453Z
Learning: The VLDocking library (com.vlsolutions.swing.docking) has a distinct component management model where UI components are added to both the frame's content pane AND registered with the DockingDesktop. Unlike standard Swing where components can only have one parent, VLDocking expects dockables to be owned by the frame while being managed by the docking desktop for layout, docking states, and behaviors.
Applied to files:
src/main/java/org/editor/panels/PluginsPanel.javasrc/main/java/org/editor/panels/VCPanel.javasrc/main/java/org/editor/panels/FileTreePanel.javasrc/main/java/org/editor/CanvasFrame.javasrc/main/java/org/editor/EditorWindow.java
📚 Learning: the vldocking library (com.vlsolutions.swing.docking) expects dockable components to be owned by the...
Learnt from: hexaredecimal
PR: Glimmr-Lang/PicassoCode#1
File: src/main/java/org/editor/EditorWindow.java:204-209
Timestamp: 2025-05-14T10:49:23.453Z
Learning: The VLDocking library (com.vlsolutions.swing.docking) expects dockable components to be owned by the frame while being managed by the docking desktop. Unlike standard Swing components that can only have one parent, the DockingDesktop acts as a manager for dockable components rather than being their parent in the component hierarchy.
Applied to files:
src/main/java/org/editor/panels/PluginsPanel.javasrc/main/java/org/editor/panels/VCPanel.javasrc/main/java/org/editor/panels/FileTreePanel.javasrc/main/java/org/editor/CanvasFrame.javasrc/main/java/org/editor/EditorWindow.java
🧬 Code Graph Analysis (6)
src/main/java/org/editor/CodeEditor.java (1)
src/main/java/org/editor/icons/Icons.java (1)
Icons(10-133)
src/main/java/org/piccode/piccode/Piccode.java (2)
src/main/java/org/editor/AccessFrame.java (2)
AccessFrame(40-279)AccessFrameOutputStream(148-277)src/main/java/org/editor/EditorWindow.java (1)
EditorWindow(61-562)
src/main/java/org/editor/events/Actions.java (1)
src/main/java/org/editor/events/MenuEvents.java (1)
MenuEvents(24-140)
src/main/java/org/editor/events/MenuEvents.java (1)
src/main/java/org/editor/EditorWindow.java (1)
EditorWindow(61-562)
src/main/java/org/editor/panels/FileTreePanel.java (1)
src/main/java/org/editor/icons/Icons.java (1)
Icons(10-133)
src/main/java/org/editor/CanvasFrame.java (1)
src/main/java/org/editor/AccessFrame.java (1)
AccessFrame(40-279)
🔇 Additional comments (33)
examples/hello.pics (1)
1-5: LGTM!This is a clean, simple example demonstrating basic I/O functionality in the PiccodeScript language. The import syntax and function call structure look appropriate for a hello world example.
src/main/java/org/editor/icons/Icons.java (1)
57-57: LGTM!The addition of the "markdown" icon to the icons array is straightforward and follows the existing pattern. This supports the UI enhancements mentioned in the PR.
src/main/java/org/editor/events/Actions.java (1)
122-122: Good refactoring to improve code organization.Replacing the inline lambda with a method reference to
MenuEvents::newFileimproves maintainability by centralizing event handling logic in dedicated methods.pom.xml (1)
14-19: LGTM! JitPack repository addition is appropriate.Adding JitPack.io repository is the correct approach for consuming GitHub-based Maven artifacts.
examples/arrays.pics (1)
1-17: Well-structured example demonstrating array operations.The example effectively showcases key array functionality including concatenation, length access, and joining operations. Good use of IO.println for output demonstration.
src/main/java/org/piccode/piccode/Piccode.java (1)
14-20: LGTM! Clean compiler configuration setup.The compiler configuration is well-structured for an IDE environment:
exitOnError = falseprevents the compiler from terminating the IDE on errorsErrorAsciiKind.EMACS_COMP_STYLEprovides consistent error formatting- Output redirection to
AccessFrame.AccessFrameOutputStream.outenables styled output in the UIThe order of operations is correct - configure the compiler before launching the editor window.
src/main/java/org/piccode/tokenmaker/PiccodeScriptTokenMaker.java (2)
60-61: LGTM! Token mapping additions are consistent.The addition of
USEandINtokens to the reserved words mapping aligns with the updated keyword list ingetWordsToHighlight.
93-93: Keywords list updated to match new language features.The keywords list now includes "in" and "use" while removing "function". This appears consistent with the language evolution shown in the example files.
examples/showcase.pics (1)
34-41: LGTM! Great demonstration of modern language features.The function definition with default parameters, named arguments, and pipeline operator usage effectively showcases advanced language capabilities.
pkg/math/math.pics (2)
22-27: LGTM! Nested structure improves readability.The refactored
clampfunction maintains the same logic while using a cleaner nested if-else structure that's easier to follow than the previous chained approach.
29-30: LGTM! Consistent formatting.The
maxandminfunctions are now properly formatted with consistent spacing.pkg/number/number.pics (4)
1-8: LGTM! Well-designed predicate functions.The numeric predicate functions (
isZero,isPositive,isNegative,isEven,isOdd) are correctly implemented with appropriate default parameters.
9-9: LGTM! Clever string conversion approach.Using string concatenation (
n + "") fortoStringis a clean way to convert numbers to strings without requiring a native function call.
11-16: Good defensive defaults for arithmetic operations.The arithmetic functions are well-implemented with safe defaults. Particularly good that
divandmoddefault the divisor to 1 to prevent division by zero errors.
21-25: LGTM! Complete bitwise operation coverage.The bitwise operations (
and,or,shl,shr) provide good coverage of common bit manipulation needs with consistent naming and defaults.src/main/java/org/editor/panels/FileTreePanel.java (2)
17-33: LGTM! Well-structured panel initialization.The constructor properly extends
DockablePaneland sets up the JTree with appropriate properties including angled lines for better visual hierarchy. The integration with the Icons system is clean.
81-94: LGTM! Well-implemented file type detection.The custom cell renderer properly handles different file types with appropriate icons. The logic correctly distinguishes between directories (with special handling for "src" folders),
.picsfiles,.mdfiles, and generic files. The use of pattern matching withinstanceof File fileis modern and clean.pkg/tuple/tuple.pics (5)
8-11: LGTM! Clean tuple mapping implementation.The
mapfunction correctly uses pattern matching to destructure the tuple and apply the function to both elements. The syntax is clean and idiomatic.
13-16: LGTM! Elegant zipWith implementation.The
zipWithfunction cleverly uses pattern matching on an array of tuples to destructure both input tuples simultaneously, then applies the function element-wise. This is a sophisticated and clean approach.
18-21: LGTM! Simple and correct swap implementation.The
swapfunction is straightforward and correctly swaps the tuple elements using pattern matching.
23-26: LGTM! Comprehensive equality comparison.The
equalsfunction properly compares both elements of the tuples using the same pattern matching approach aszipWith. The logic correctly usesandto ensure both elements match.
28-31: LGTM! Consistent string representation.The
toStringfunction provides a standard tuple representation format with parentheses and comma separation, consistent with mathematical notation.pkg/string/string.pics (4)
8-8: LGTM! Simplified length implementation.Refactoring to use the
.lenproperty directly instead of calling a native function is cleaner and more efficient.
15-19: LGTM! Well-implemented left padding.The
padLeftfunction correctly calculates the padding needed and handles edge cases where no padding is required. The use of adoblock for the let binding is appropriate.
21-25: LGTM! Consistent right padding implementation.The
padRightfunction mirrors thepadLeftlogic appropriately, with the only difference being the concatenation order. Good consistency in implementation approach.
16-16: Verify module self-reference syntax for String.lengthEnsure the new compiler API supports self-referencing calls to
String.length(str)within the same module. If it does not, update these to the correct local invocation (e.g.length(str)or appropriate import).Occurrences to check:
- pkg/string/string.pics:16
- pkg/string/string.pics:22
src/main/java/org/editor/AccessFrame.java (2)
148-178: Well-implemented output stream with proper buffering.The
AccessFrameOutputStreamimplementation correctly handles buffering, UTF-8 encoding, and thread safety throughSwingUtilities.invokeLater.
148-277: Well-implemented ANSI output stream handlerThe
AccessFrameOutputStreamimplementation is well-designed with proper thread safety, ANSI escape code handling, and styled text output. The use ofSwingUtilities.invokeLaterensures UI updates happen on the EDT.src/main/java/org/editor/EditorWindow.java (3)
200-225: Correct implementation of VLDocking pattern.The panels are properly added to both the frame's content pane and the DockingDesktop, following VLDocking's component management model. The auto-hide configuration is appropriate for auxiliary panels.
208-210: Multiple components added to the same BorderLayout positionAdding multiple components to
BorderLayout.EASTwill cause only the last one to be visible. Based on the VLDocking library usage pattern, this appears intentional for dockable registration.
303-305: Good defensive programming for null safetyThe addition of null check when no editors exist prevents potential NPE.
pkg/array/array.pics (2)
4-17: Well-implemented recursive array operations.The
concatandjoinfunctions correctly use pattern matching and handle all edge cases properly. The recursive implementations are clean and efficient.
26-85: Excellent functional programming implementations.The higher-order functions (
map,filter,reduce, etc.) are implemented correctly with proper pattern matching and edge case handling. The functional style is consistent and the code is readable.
examples/arrays.pics
Outdated
|
|
||
| IO.println(collon_sep) | ||
|
|
||
| let new = collon_sep:concat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Consider renaming variable and verify concatenation syntax.
Using new as a variable name may conflict with reserved keywords in some contexts. Also ensure the : concatenation operator syntax is correct for PiccodeScript.
-let new = collon_sep:concat
+let combined = colon_sep:concat🏁 Script executed:
#!/bin/bash
# Description: Verify PiccodeScript language syntax for string concatenation and reserved keywords
# Search for concatenation operator usage in other example files
echo "Checking concatenation operator usage in examples..."
fd -e pics -x grep -H ":" {} \; | grep -v "import\|//"
# Search for 'new' keyword usage as variable name
echo "Checking 'new' keyword usage..."
fd -e pics -x grep -H "let new\|var new" {} \;Length of output: 1374
Rename the new variable and correct the diff
The : operator for method references is used consistently across examples, so the syntax is valid. To avoid a reserved-word conflict and reference the existing collon_sep binding, update line 16 in examples/arrays.pics:
-let new = collon_sep:concat
+let combined = collon_sep:concat📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let new = collon_sep:concat | |
| let combined = collon_sep:concat |
🤖 Prompt for AI Agents
In examples/arrays.pics at line 16, the variable named `new` conflicts with a
reserved word. Rename this variable to a valid identifier that does not clash
with reserved keywords, and ensure the method reference using the `:` operator
with `collon_sep` remains unchanged and correctly references the existing
binding.
examples/showcase.pics
Outdated
| is (a, b, c) -> a + " " + b + " " + c | ||
| else -> "Not a match"" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix syntax error in pattern matching.
There's a syntax error in the when expression - missing closing quote.
when numbers {
is (a, b, c) -> a + " " + b + " " + c
- else -> "Not a match""
+ else -> "Not a match"
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| is (a, b, c) -> a + " " + b + " " + c | |
| else -> "Not a match"" | |
| } | |
| when numbers { | |
| is (a, b, c) -> a + " " + b + " " + c | |
| else -> "Not a match" | |
| } |
🤖 Prompt for AI Agents
In examples/showcase.pics around lines 29 to 31, there is a syntax error in the
when expression due to an extra or missing quote in the else branch string "Not
a match"". Remove the extra quote so that the string is properly closed,
ensuring correct syntax for the pattern matching expression.
pkg/array/array.pics
Outdated
| is x:rest -> x : concat(rest, b) | ||
| } | ||
|
|
||
| function toString(arr=[]) = pic_nat_array_tostring(arr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Native function call may fail - implement toString recursively.
The pic_nat_array_tostring native function may not exist since the runtime modules were removed. Consider implementing this recursively like the other functions.
- function toString(arr=[]) = pic_nat_array_tostring(arr)
+ function toString(arr=[]) = "[" + join(map(arr, |x| -> x.toString()), ", ") + "]"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| function toString(arr=[]) = pic_nat_array_tostring(arr) | |
| function toString(arr=[]) = "[" + join(map(arr, |x| -> x.toString()), ", ") + "]" |
🤖 Prompt for AI Agents
In pkg/array/array.pics at line 10, the toString function currently calls the
native function pic_nat_array_tostring, which may not exist due to removed
runtime modules. Replace this native call by implementing toString recursively:
define the function to handle an array by converting each element to a string
(recursively if elements are arrays) and concatenating them appropriately to
produce the full string representation.
pkg/math/math.pics
Outdated
| function factorial(n=0) = | ||
| if n <= 1 { 1 } | ||
| else { n * factorial(n - 1) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add safeguards for factorial function.
The recursive factorial implementation lacks protection against stack overflow for large inputs and doesn't handle negative numbers appropriately.
function factorial(n=0) =
+ if n < 0 { 0 } // or throw error for negative input
if n <= 1 { 1 }
else { n * factorial(n - 1) }Consider adding documentation about the practical limits (typically n < 1000 to avoid stack overflow) or implementing an iterative version for better performance.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In pkg/math/math.pics around lines 38 to 40, the factorial function lacks
safeguards against negative inputs and potential stack overflow from deep
recursion. Add a check to handle negative numbers by returning an error or a
defined value. Consider rewriting the function iteratively to avoid recursion
depth issues, or document the practical input limits (e.g., n < 1000) to inform
users about performance and safety constraints.
pkg/string/string.pics
Outdated
| function repeat(str="", n=0) = | ||
| if n <= 0 { "" } | ||
| else { str + repeat(str, n - 1) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add safeguards for repeat function.
The recursive repeat implementation lacks protection against stack overflow for large n values and doesn't handle negative inputs.
function repeat(str="", n=0) =
+ if n < 0 { "" } // Handle negative input
if n <= 0 { "" }
else { str + repeat(str, n - 1) }Consider implementing an iterative version for better performance with large repeat counts to avoid stack overflow.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In pkg/string/string.pics around lines 11 to 13, the recursive repeat function
risks stack overflow with large n and does not handle negative inputs properly.
Replace the recursive implementation with an iterative approach that uses a loop
to concatenate the string n times, and add a check to return an empty string if
n is negative or zero to safeguard against invalid inputs and improve
performance.
| CanvasFrame.file = file; | ||
| CanvasFrame.code = code; | ||
| CanvasFrame.start = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify thread safety of static field approach.
Using static fields (CanvasFrame.file, CanvasFrame.code, CanvasFrame.start) for inter-component communication raises concurrency concerns:
- Race conditions if multiple compile requests occur simultaneously
- State consistency issues if compilation is interrupted
- Memory visibility problems without proper synchronization
🏁 Script executed:
#!/bin/bash
# Check how CanvasFrame handles these static fields and thread safety
echo "Searching for CanvasFrame static field usage..."
rg -A 10 -B 2 "CanvasFrame\.(file|code|start)" . --type=java
echo "Searching for thread/synchronization in CanvasFrame..."
rg -A 5 -B 2 "Thread|synchronized|volatile|AtomicReference" . --type=java | grep -i canvasLength of output: 2027
🏁 Script executed:
#!/bin/bash
# List all static field declarations in CanvasFrame.java
echo "=== Static field declarations ==="
rg -n "static " src/main/java/org/editor/CanvasFrame.java
# Show the compileFrame method to see how it consumes the static fields
echo -e "\n=== compileFrame() implementation ==="
rg -A 20 -B 2 "void compileFrame" src/main/java/org/editor/CanvasFrame.javaLength of output: 715
Thread-safety risk: avoid mutable static fields for compile data
Using
CanvasFrame.file = file;
CanvasFrame.code = code;
CanvasFrame.start = true; to shuttle data into a newly‐spawned thread (via SwingUtilities.invokeLater(…new Thread(() -> compileFrame())…)) exposes you to:
- Race conditions when two compile actions fire in quick succession—one request can clobber the other’s
file/codebefore it’s read - Memory‐visibility issues: no
volatileor synchronization guarantees that the worker thread ever sees the latest values - Hard-to-trace state consistency bugs when compilation aborts or errors occur
Please refactor to eliminate these statics. For example:
- Change
compileFrame()to accept(String file, String code)parameters - Pass the data directly into the new thread rather than mutating globals
- Or encapsulate requests in a thread-safe queue or use Java’s concurrency primitives (
volatile,synchronized, locks) if shared state is unavoidable
Locations to update:
- src/main/java/org/editor/events/AccessEvents.java (lines 32–34)
- src/main/java/org/editor/CanvasFrame.java (static fields
file,code,startand thenew Thread(() -> compileFrame())…invocation)
🤖 Prompt for AI Agents
In src/main/java/org/editor/events/AccessEvents.java around lines 32 to 34,
avoid using mutable static fields CanvasFrame.file, CanvasFrame.code, and
CanvasFrame.start to pass data to the compile thread, as this causes
thread-safety issues. Refactor compileFrame() to accept file and code as
parameters, then pass these directly into the new thread or
SwingUtilities.invokeLater call instead of setting static fields. Also update
src/main/java/org/editor/CanvasFrame.java to remove the static fields and modify
the thread invocation accordingly to ensure data is passed safely without shared
mutable state.
| public static void compile(ActionEvent e) { | ||
| var ed = EditorWindow.getSelectedEditor(); | ||
| if (ed == null) { | ||
| return; | ||
| } | ||
| var code = ed.textArea.getText(); | ||
|
|
||
| if (ed.file == null) { | ||
| EditorWindow.current_file.setText("Cannot compiler unsaved code"); | ||
| return; | ||
| } | ||
|
|
||
| var code = ed.textArea.getText(); | ||
| AccessFrame.writeSuccess("Compilation started: "); | ||
| Compiler.compile(code, false); | ||
| Compiler.out = AccessFrame.AccessFrameOutputStream.out; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete implementation: compile method doesn't actually compile.
The compile method only redirects the output stream but doesn't trigger any actual compilation. This seems incomplete compared to compileAndRender which sets the CanvasFrame fields to trigger compilation.
Either:
- Complete the implementation by adding compilation trigger logic
- Remove the method if it's no longer needed
- Add a TODO comment explaining the intended behavior
public static void compile(ActionEvent e) {
// ... null checks ...
var code = ed.textArea.getText();
AccessFrame.writeSuccess("Compilation started: ");
Compiler.out = AccessFrame.AccessFrameOutputStream.out;
+
+ // TODO: Add actual compilation logic or remove this method
+ // Currently only redirects output but doesn't compile
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public static void compile(ActionEvent e) { | |
| var ed = EditorWindow.getSelectedEditor(); | |
| if (ed == null) { | |
| return; | |
| } | |
| var code = ed.textArea.getText(); | |
| if (ed.file == null) { | |
| EditorWindow.current_file.setText("Cannot compiler unsaved code"); | |
| return; | |
| } | |
| var code = ed.textArea.getText(); | |
| AccessFrame.writeSuccess("Compilation started: "); | |
| Compiler.compile(code, false); | |
| Compiler.out = AccessFrame.AccessFrameOutputStream.out; | |
| } | |
| public static void compile(ActionEvent e) { | |
| var ed = EditorWindow.getSelectedEditor(); | |
| if (ed == null) { | |
| return; | |
| } | |
| if (ed.file == null) { | |
| EditorWindow.current_file.setText("Cannot compiler unsaved code"); | |
| return; | |
| } | |
| var code = ed.textArea.getText(); | |
| AccessFrame.writeSuccess("Compilation started: "); | |
| Compiler.out = AccessFrame.AccessFrameOutputStream.out; | |
| // TODO: Add actual compilation logic or remove this method | |
| // Currently only redirects output but doesn't compile | |
| } |
🤖 Prompt for AI Agents
In src/main/java/org/editor/events/AccessEvents.java between lines 38 and 52,
the compile method sets up output redirection but does not actually trigger any
compilation process, making it incomplete. To fix this, either implement the
compilation logic similar to compileAndRender by invoking the necessary compiler
methods and updating CanvasFrame fields, or if this method is obsolete, remove
it entirely. Alternatively, add a clear TODO comment explaining that the
compilation trigger logic needs to be implemented later.
| if (ed.file == null) { | ||
| EditorWindow.current_file.setText("Cannot compiler unsaved code"); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typo in error message (duplicate issue).
Same typo appears in the compile method.
- EditorWindow.current_file.setText("Cannot compiler unsaved code");
+ EditorWindow.current_file.setText("Cannot compile unsaved code");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (ed.file == null) { | |
| EditorWindow.current_file.setText("Cannot compiler unsaved code"); | |
| return; | |
| } | |
| if (ed.file == null) { | |
| EditorWindow.current_file.setText("Cannot compile unsaved code"); | |
| return; | |
| } |
🤖 Prompt for AI Agents
In src/main/java/org/editor/events/AccessEvents.java around lines 44 to 47, the
error message "Cannot compiler unsaved code" contains a typo. Change "compiler"
to "compile" in the string passed to EditorWindow.current_file.setText. Also,
locate the similar typo in the compile method and correct it the same way to
maintain consistency.
| private void createNodes(DefaultMutableTreeNode top, File fp) { | ||
| File[] files = fp.listFiles(); | ||
|
|
||
| for (File file : files) { | ||
| if (file.isFile()) { | ||
| DefaultMutableTreeNode f = new DefaultMutableTreeNode(file); | ||
| top.add(f); | ||
| } else { | ||
| DefaultMutableTreeNode dir = new DefaultMutableTreeNode(file); | ||
| createNodes(dir, file); | ||
| top.add(dir); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add null check for listFiles() result.
The createNodes method doesn't handle the case where fp.listFiles() returns null, which can happen due to I/O errors or permission issues.
private void createNodes(DefaultMutableTreeNode top, File fp) {
File[] files = fp.listFiles();
+ if (files == null) {
+ return; // Handle case where listFiles() returns null
+ }
for (File file : files) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private void createNodes(DefaultMutableTreeNode top, File fp) { | |
| File[] files = fp.listFiles(); | |
| for (File file : files) { | |
| if (file.isFile()) { | |
| DefaultMutableTreeNode f = new DefaultMutableTreeNode(file); | |
| top.add(f); | |
| } else { | |
| DefaultMutableTreeNode dir = new DefaultMutableTreeNode(file); | |
| createNodes(dir, file); | |
| top.add(dir); | |
| } | |
| } | |
| } | |
| private void createNodes(DefaultMutableTreeNode top, File fp) { | |
| File[] files = fp.listFiles(); | |
| if (files == null) { | |
| return; // Handle case where listFiles() returns null | |
| } | |
| for (File file : files) { | |
| if (file.isFile()) { | |
| DefaultMutableTreeNode f = new DefaultMutableTreeNode(file); | |
| top.add(f); | |
| } else { | |
| DefaultMutableTreeNode dir = new DefaultMutableTreeNode(file); | |
| createNodes(dir, file); | |
| top.add(dir); | |
| } | |
| } | |
| } |
🤖 Prompt for AI Agents
In src/main/java/org/editor/panels/FileTreePanel.java around lines 55 to 68, the
createNodes method calls fp.listFiles() without checking if the result is null,
which can cause a NullPointerException if listFiles() fails due to I/O errors or
permission issues. Add a null check after calling listFiles() and only proceed
with the for loop if the files array is not null.
|
|
||
| public class PiccodeScriptTokenMaker extends AbstractTokenMaker { | ||
| private static List<String> importants = List.of("pkg", "remote", "super", "true", "false"); | ||
| private static List<String> importants = List.of("true", "false", "await"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify keyword consistency with language specification.
The keywords list has been significantly changed from ["pkg", "remote", "super", "true", "false"] to ["true", "false", "await"]. This removes several keywords that might still be in use.
🏁 Script executed:
#!/bin/bash
# Search for usage of removed keywords in example files and source code
echo "Searching for removed keywords usage..."
rg -n "pkg|remote|super" examples/ --type=pics 2>/dev/null || echo "No .pics files found"
rg -n "pkg|remote|super" . --type=java -A 2Length of output: 5130
Remove outdated ‘pkg’ shorthand completion to align with updated keywords
All removed keywords (pkg, remote, super) no longer appear in any .pics examples or in the token‐maker grammar. However, the editor still registers a shorthand completion for pkg, which is now invalid:
• src/main/java/org/editor/CodeEditor.java:245
- provider.addCompletion(new ShorthandCompletion(provider, "pkg", "input pkg:"));Please remove (or update) this line so the editor’s completions match the new language specification.
🤖 Prompt for AI Agents
In src/main/java/org/piccode/tokenmaker/PiccodeScriptTokenMaker.java at line 20,
remove the outdated keyword "pkg" from the list of important keywords to ensure
the editor's shorthand completions align with the updated language specification
and no longer include invalid completions.
Summary by CodeRabbit
New Features
Bug Fixes
Chores