-
-
Notifications
You must be signed in to change notification settings - Fork 0
chore: release 0.1.9 #10
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
Changes from all commits
e197b92
c23502b
49e5414
f52facf
31097d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,9 @@ | |
| * Lexer for PEG grammar syntax. | ||
| */ | ||
| public final class GrammarLexer { | ||
| private static final int MAX_INPUT_SIZE = 1_000_000; | ||
| private static final int DEFAULT_TOKEN_CAPACITY = 32; | ||
|
|
||
|
Comment on lines
+13
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid throwing in tokenize(): return a lexer error token to keep Result-based flow.
Proposed fix (keep signature, no exception) public static List<GrammarToken> tokenize(String input) {
- if (input.length() > MAX_INPUT_SIZE) {
- throw new IllegalArgumentException(
- "Grammar input exceeds maximum size of " + MAX_INPUT_SIZE + " characters");
- }
- return new GrammarLexer(input).tokenizeAll();
+ if (input.length() > MAX_INPUT_SIZE) {
+ var loc = SourceLocation.at(1, 1, 0);
+ var span = SourceSpan.at(loc);
+ return List.of(
+ new GrammarToken.Error(span, "Grammar input exceeds maximum size of " + MAX_INPUT_SIZE + " characters"),
+ new GrammarToken.Eof(span)
+ );
+ }
+ return new GrammarLexer(input).tokenizeAll();
}Also applies to: 29-33 🤖 Prompt for AI Agents |
||
| private final String input; | ||
| private int pos; | ||
| private int line; | ||
|
|
@@ -23,6 +26,10 @@ private GrammarLexer(String input) { | |
| } | ||
|
|
||
| public static List<GrammarToken> tokenize(String input) { | ||
| if (input.length() > MAX_INPUT_SIZE) { | ||
| throw new IllegalArgumentException( | ||
| "Grammar input exceeds maximum size of " + MAX_INPUT_SIZE + " characters"); | ||
| } | ||
| return new GrammarLexer(input).tokenizeAll(); | ||
| } | ||
|
|
||
|
|
@@ -75,7 +82,7 @@ private GrammarToken nextToken() { | |
| } | ||
|
|
||
| private GrammarToken scanIdentifier(SourceLocation start) { | ||
| var sb = new StringBuilder(); | ||
| var sb = new StringBuilder(DEFAULT_TOKEN_CAPACITY); | ||
| while (!isAtEnd() && isIdentifierPart(peek())) { | ||
| sb.append(advance()); | ||
| } | ||
|
|
@@ -85,7 +92,7 @@ private GrammarToken scanIdentifier(SourceLocation start) { | |
| private GrammarToken scanDirective(SourceLocation start) { | ||
| advance(); | ||
| // skip % | ||
| var sb = new StringBuilder(); | ||
| var sb = new StringBuilder(DEFAULT_TOKEN_CAPACITY); | ||
| while (!isAtEnd() && isIdentifierPart(peek())) { | ||
| sb.append(advance()); | ||
| } | ||
|
|
@@ -94,7 +101,7 @@ private GrammarToken scanDirective(SourceLocation start) { | |
|
|
||
| private GrammarToken scanStringLiteral(SourceLocation start) { | ||
| char quote = advance(); | ||
| var sb = new StringBuilder(); | ||
| var sb = new StringBuilder(DEFAULT_TOKEN_CAPACITY); | ||
| while (!isAtEnd() && peek() != quote) { | ||
| if (peek() == '\\' && pos + 1 < input.length()) { | ||
| advance(); | ||
|
|
@@ -125,7 +132,7 @@ private GrammarToken scanCharClass(SourceLocation start) { | |
| negated = true; | ||
| advance(); | ||
| } | ||
| var sb = new StringBuilder(); | ||
| var sb = new StringBuilder(DEFAULT_TOKEN_CAPACITY); | ||
| while (!isAtEnd() && peek() != ']') { | ||
| if (peek() == '\\' && pos + 1 < input.length()) { | ||
| advance(); | ||
|
|
@@ -163,7 +170,7 @@ private GrammarToken scanCharClass(SourceLocation start) { | |
| private GrammarToken scanActionCode(SourceLocation start) { | ||
| advance(); | ||
| // skip { | ||
| var sb = new StringBuilder(); | ||
| var sb = new StringBuilder(DEFAULT_TOKEN_CAPACITY); | ||
| int braceDepth = 1; | ||
| while (!isAtEnd() && braceDepth > 0) { | ||
| char c = peek(); | ||
|
|
@@ -192,7 +199,7 @@ private GrammarToken scanActionCode(SourceLocation start) { | |
| } | ||
|
|
||
| private String scanJavaString() { | ||
| var sb = new StringBuilder(); | ||
| var sb = new StringBuilder(DEFAULT_TOKEN_CAPACITY); | ||
| char quote = advance(); | ||
| sb.append(quote); | ||
| while (!isAtEnd() && peek() != quote) { | ||
|
|
@@ -208,7 +215,7 @@ private String scanJavaString() { | |
| } | ||
|
|
||
| private GrammarToken scanNumber(SourceLocation start) { | ||
| var sb = new StringBuilder(); | ||
| var sb = new StringBuilder(DEFAULT_TOKEN_CAPACITY); | ||
| while (!isAtEnd() && isDigit(peek())) { | ||
| sb.append(advance()); | ||
| } | ||
|
|
||
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.
🧩 Analysis chain
🏁 Script executed:
cat -n pom.xml | head -60Repository: siy/java-peglib
Length of output: 2543
🏁 Script executed:
Repository: siy/java-peglib
Length of output: 547
🌐 Web query:
pragmatica-lite 0.9.10 maven central release💡 Result:
I couldn't find pragmatica-lite version 0.9.10 on Maven Central. The Maven Central group listing and package pages show other versions (e.g. tcp 0.9.8, core up to ~0.9.0 / 0.8.x), but no 0.9.10 release. [1][2][3]
Sources:
Want me to watch for a 0.9.10 release and notify you when it appears?
🌐 Web query:
pragmatica-lite releases changelog 0.9.0 0.9.10💡 Result:
Do you mean the pragmatica-lite "pragmatica-lite" artifact (or a specific module like core, tcp, etc.) — and do you want the full changelog entries for versions 0.9.0 and 0.9.10 or just a short summary?
🏁 Script executed:
Repository: siy/java-peglib
Length of output: 120
🏁 Script executed:
Repository: siy/java-peglib
Length of output: 720
Update pragmatica-lite:core dependency version to 0.9.0 per coding guideline.
The pom.xml specifies pragmatica-lite:core 0.9.10, but the coding guideline requires version 0.9.0 as the only runtime dependency. While 0.9.10 has been released (2026-01-07), the dependency version must align with the stated requirement.
pragmatica-lite:core is correctly the only runtime dependency; only the version number requires adjustment.
🤖 Prompt for AI Agents