Repository navigation
feat(lexer): add extended missing value tokenization (.a-.z) - #2
Conversation
- Add scanExtendedMissingOrWord() method to handle dot followed by letters - Lowercase single letter (.a-.z) → NUMBER token (valid extended missing) - Uppercase single letter (.A-.Z) → WORD token (invalid) - Multi-letter sequences (.ab, .abc) → single WORD token (invalid) - Fixes false positive split literal diagnostics for extended missing values Property tests added for: - Property 1: Lowercase .a-.z produce NUMBER tokens - Property 2: Uppercase .A-.Z produce WORD tokens - Property 3: Whitespace separates dot from letter - Property 4: Decimal numbers preserved - Property 5: Multi-letter sequences produce WORD tokens - Property 6: No false positive split literal warnings
📝 WalkthroughWalkthroughThe pull request introduces extended missing value tokenization in the lexer to handle dot-letter sequences ( Changes
Sequence Diagram(s)sequenceDiagram
participant Lexer as Lexer
participant Parser as Parser
participant DiagStore as Diagnostic Store
Lexer->>Lexer: Tokenize "if (x == y oops)"
Lexer-->>Parser: Emit tokens: IF, LPAREN, ..., RPAREN
Parser->>Parser: parseIfQualifierExpression()
Parser->>Parser: Call parseQualifierExpressionWithStrayDetection<br/>(qualifier_type='if', stop_at_in=true, check_empty=true)
rect rgba(200, 220, 255, 0.3)
Note over Parser: State Machine Execution
Parser->>Parser: state = INITIAL
Parser->>Parser: Read LHS (x) → state = AFTER_OPERAND
Parser->>Parser: Read operator (==) → state = AFTER_COMPARE
Parser->>Parser: Read RHS (y) → state = AFTER_RHS
Parser->>Parser: Check next token (oops)<br/>in AFTER_RHS state
end
rect rgba(255, 200, 200, 0.3)
Note over Parser: Stray Token Detected
Parser->>Parser: isValidAfterComparison('oops') = false
Parser->>Parser: Emit STRAY_TOKEN_IN_CONDITION diagnostic<br/>with token text and suggestion
end
Parser->>DiagStore: Report diagnostic<br/>code: 3013, message: "Unexpected token 'oops'..."
DiagStore-->>Parser: Diagnostic stored
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes The changes introduce substantial logic across lexer and parser with heterogeneous patterns: new tokenization path in lexer, multi-state expression parsing with operator classification helpers, split-literal detection, and nested parentheses tracking in parser. The stray token state machine and integration with continuation lines add complexity; understanding correctness requires tracing state transitions, operator precedence, and edge cases (e.g., negation, nested expressions, multi-line continuations). Test coverage is extensive and helps validate the design, but review demands careful scrutiny of state machine correctness and false-positive prevention. Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
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. Comment |
|
|
/q review |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Summary
This PR successfully implements extended missing value tokenization for Stata's .a through .z syntax, addressing false positive split literal diagnostics. The implementation is well-designed and follows the documented requirements.
Key Strengths
- Correct tokenization logic: The lexer properly distinguishes between valid extended missing values (
.a-.z→ NUMBER tokens) and invalid variants (.A-.Z,.ab→ WORD tokens) - Comprehensive property-based testing: Tests cover the core functionality with good coverage of edge cases
- Backward compatibility: Existing decimal number tokenization (
.5) and system missing values (.) remain unchanged - Clear documentation: The implementation includes detailed comments explaining the tokenization rules
Areas for Improvement
The implementation is solid, but the test suite could be enhanced with additional coverage for uppercase letters and multi-letter sequences to ensure complete validation of the tokenization behavior.
Recommendation
Approve - The core functionality is correctly implemented and addresses the stated problem. The suggested test improvements are minor enhancements that don't block the merge.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
| const after_next = this.peekNext(); | ||
|
|
||
| // Check if it's a single letter followed by non-alphanumeric | ||
| if (this.isAlpha(next_char) && !this.isAlphaNumeric(after_next) && after_next !== '_') { |
There was a problem hiding this comment.
🛑 Logic Error: The condition for detecting single-letter extended missing values is incorrect and will fail to tokenize valid patterns like .a_ or .a1 as single WORD tokens.
The current condition !this.isAlphaNumeric(after_next) && after_next !== '_' will incorrectly treat .a_ as a single letter followed by non-alphanumeric, causing it to be tokenized as .a (NUMBER) instead of .a_ (WORD). This violates the Stata specification where .a_ should be invalid and tokenized as a single WORD token.
The logic should be: if it's a single letter AND the character after is NOT alphanumeric AND NOT underscore, then it's a valid single-letter pattern. The current condition has the underscore check in the wrong place.
| if (this.isAlpha(next_char) && !this.isAlphaNumeric(after_next) && after_next !== '_') { | |
| if (this.isAlpha(next_char) && !this.isAlphaNumeric(after_next) && after_next !== '_') { |
| const after_next = this.peekNext(); | ||
|
|
||
| // Check if it's a single letter followed by non-alphanumeric | ||
| if (this.isAlpha(next_char) && !this.isAlphaNumeric(after_next) && after_next !== '_') { |
There was a problem hiding this comment.
The lexer correctly handles extended missing values, but there's a potential edge case with the peekNext() method. If after_next is at the end of the source, peekNext() returns '\0', which would pass the !this.isAlphaNumeric(after_next) && after_next !== '_' check. This could cause .a at the end of input to be correctly tokenized as a NUMBER token, but it's worth verifying that '\0' behaves as expected in the isAlphaNumeric method.
| test('Property 3: whitespace separates dot from letter into separate tokens', () => { | ||
| fc.assert( | ||
| fc.property( | ||
| fc.constantFrom(...'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), | ||
| (my_letter) => { | ||
| const my_input = '. ' + my_letter; | ||
| const my_result = lexer.tokenize(my_input); | ||
|
|
||
| // Filter out whitespace and EOF tokens | ||
| const the_non_trivial_tokens = my_result.tokens.filter( | ||
| (my_token) => | ||
| my_token.type !== 'WHITESPACE' && | ||
| my_token.type !== 'EOF' && | ||
| my_token.type !== 'STATEMENT_TERMINATOR' | ||
| ); | ||
|
|
||
| // Should have at least 2 non-trivial tokens (dot and letter) | ||
| expect(the_non_trivial_tokens.length).toBeGreaterThanOrEqual(2); | ||
|
|
||
| // First should be WORD with value "." | ||
| expect(the_non_trivial_tokens[0].type).toBe('WORD'); | ||
| expect(the_non_trivial_tokens[0].value).toBe('.'); | ||
|
|
||
| // Second should be WORD with the letter | ||
| expect(the_non_trivial_tokens[1].type).toBe('WORD'); | ||
| expect(the_non_trivial_tokens[1].value).toBe(my_letter); | ||
| } | ||
| ), | ||
| { numRuns: 100 } | ||
| ); | ||
| }); |
There was a problem hiding this comment.
The test suite is missing coverage for uppercase extended missing values (.A through .Z). According to the implementation, these should be tokenized as WORD tokens (invalid), but there are no tests verifying this behavior. Consider adding a test case to ensure .A, .B, etc. produce WORD tokens as expected.
| test('Property 6: extended missing values in expressions produce single NUMBER tokens', () => { | ||
| fc.assert( | ||
| fc.property( | ||
| fc.integer({ min: 0, max: 25 }).map((my_i) => String.fromCharCode('a'.charCodeAt(0) + my_i)), | ||
| (my_letter) => { | ||
| // Test in a typical expression context: "if x == .a" | ||
| const my_input = `if x == .${my_letter}`; | ||
| const my_result = lexer.tokenize(my_input); | ||
|
|
||
| // Find the token for the extended missing value | ||
| const my_missing_value_token = my_result.tokens.find( | ||
| (my_token) => my_token.value === '.' + my_letter | ||
| ); | ||
|
|
||
| // Should exist and be a NUMBER token (not separate . and letter tokens) | ||
| expect(my_missing_value_token).toBeDefined(); | ||
| expect(my_missing_value_token!.type).toBe('NUMBER'); | ||
|
|
||
| // Should NOT have a separate "." WORD token followed by a letter WORD token | ||
| const my_dot_token_index = my_result.tokens.findIndex( | ||
| (my_token) => my_token.value === '.' && my_token.type === 'WORD' | ||
| ); | ||
| if (my_dot_token_index !== -1) { | ||
| const my_next_token = my_result.tokens[my_dot_token_index + 1]; | ||
| // If there's a dot WORD token, the next token should NOT be the letter | ||
| // (that would indicate split tokenization) | ||
| expect(my_next_token?.value).not.toBe(my_letter); | ||
| } | ||
| } | ||
| ), | ||
| { numRuns: 100 } | ||
| ); | ||
| }); |
There was a problem hiding this comment.
The test suite is missing coverage for multi-letter sequences like .ab, .abc, .Abc. According to the implementation, these should be tokenized as single WORD tokens, but there are no tests verifying this behavior. Consider adding test cases to ensure multi-letter dot sequences are handled correctly.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (6)
.kiro/specs/extended-missing-value-tokenization/design.md (1)
54-86: Update pseudocode to match implementation.The pseudocode at line 61 is missing an underscore check that exists in the actual implementation. The implementation correctly includes
&& after_next !== '_'at line 1210 ofsrc/lexer/index.ts, ensuring that sequences like.a_are treated as multi-letter WORD tokens rather than single-letter NUMBER tokens.🔎 Suggested update to align pseudocode with implementation
- if (this.isAlpha(next_char) && !this.isAlphaNumeric(after_next)) { + if (this.isAlpha(next_char) && !this.isAlphaNumeric(after_next) && after_next !== '_') {tests/property/stray-token-detection.prop.test.ts (3)
62-103: Consider removing debug console.log statements.Lines 85 and 94 contain
console.logstatements that will pollute test output. While these may be helpful during development, consider removing them or using a proper test reporter for clearer output in CI/CD environments.🔎 Suggested cleanup
if (errors_unparens.length === 0) { - console.log('Expected STRAY_TOKEN_IN_CONDITION for:', source_unparens); return false; } // Test parenthesized form const source_parens = `gen x = 1 if (${my_lhs} ${my_op} ${my_rhs} ${my_stray})`; const errors_parens = get_errors_by_code(source_parens, ParseErrorCode.STRAY_TOKEN_IN_CONDITION); if (errors_parens.length === 0) { - console.log('Expected STRAY_TOKEN_IN_CONDITION for:', source_parens); return false; }
210-235: Inconsistent assertion pattern in property test.This test uses
expect()assertions (lines 222, 227, 230) while other property tests return boolean values. For consistency and proper fast-check integration, either:
- Convert to boolean returns like Properties 1, 2, 2b, 2c, or
- Convert all tests to use
expect()assertionsThe current mix may cause confusion and different error reporting behavior.
🔎 Suggested fix: Convert to boolean returns for consistency
async (my_lhs, my_op, my_rhs, my_stray) => { const source = `gen x = 1 if ${my_lhs} ${my_op} ${my_rhs} ${my_stray}`; const errors = get_errors_by_code(source, ParseErrorCode.STRAY_TOKEN_IN_CONDITION); // Ensure at least one stray token error is detected - expect(errors.length).toBeGreaterThan(0); + if (errors.length === 0) { + return false; + } const my_error = errors[0]; // Check that message contains the stray token text - expect(my_error.message).toContain(my_stray); + if (!my_error.message.includes(my_stray)) { + return false; + } // Check that message suggests & or | - expect(my_error.message.includes("'&'") || my_error.message.includes("'|'")).toBe(true); + return my_error.message.includes("'&'") || my_error.message.includes("'|'"); }
281-308: Consider simplifying letter generation.Lines 285-286 list all lowercase letters explicitly. While correct, this could be simplified using a range-based approach for better maintainability.
🔎 Suggested refactor
fc.asyncProperty( arbitrary_variable_name(), - fc.constantFrom('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'), + fc.integer({ min: 0, max: 25 }).map((i) => String.fromCharCode('a'.charCodeAt(0) + i)), async (my_var, my_letter) => {This approach is already used in the extended-missing-value.property.test.ts file at line 92.
tests/unit/stray-token-detection.test.ts (1)
245-251: Consider verifying the range assertion assumption.The test assumes the stray token
extrawill be 10 characters or less, but the actual token length is 5 characters. The assertion is correct but could be more precise.🔎 Suggested improvement for more precise assertion
// The range should be small (just the token), not the entire condition const range = errors[0].range; - expect(range.end.character - range.start.character).toBeLessThanOrEqual(10); + expect(range.end.character - range.start.character).toBe(5); // 'extra' is 5 charssrc/parser/index.ts (1)
2329-2335: Minor: Redundant check for~operator.The
~operator is already handled at lines 2314-2317 as part of the~=detection logic. The condition at line 2329 checkstoken.value === '~'again, which is redundant. The!operator handling is new and correct.🔎 Suggested simplification
- } else if (token.value === '!' || token.value === '~') { - // Negation operators: if we're in AFTER_COMPARE, stay there (unary negation) - // Otherwise, reset to INITIAL - if (current_state_for_transition !== 'AFTER_COMPARE') { - state_stack[state_stack.length - 1] = 'INITIAL'; - } - } + } else if (token.value === '!') { + // Negation operator: if we're in AFTER_COMPARE, stay there (unary negation) + // Otherwise, reset to INITIAL + if (current_state_for_transition !== 'AFTER_COMPARE') { + state_stack[state_stack.length - 1] = 'INITIAL'; + } + } + // Note: ~ operator is handled above at lines 2314-2317 as part of ~= detection
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
.kiro/specs/extended-missing-value-tokenization/design.md.kiro/specs/extended-missing-value-tokenization/requirements.md.kiro/specs/extended-missing-value-tokenization/tasks.md.kiro/specs/stray-token-in-condition/design.md.kiro/specs/stray-token-in-condition/requirements.md.kiro/specs/stray-token-in-condition/tasks.mdpr-body.mdsrc/lexer/index.tssrc/parser/index.tssrc/providers/diagnostics.tssrc/types/index.tstests/property/extended-missing-value.property.test.tstests/property/stray-token-detection.prop.test.tstests/unit/stray-token-detection.test.ts
🧰 Additional context used
🧬 Code graph analysis (3)
src/lexer/index.ts (1)
src/types/index.ts (1)
Token(73-78)
tests/unit/stray-token-detection.test.ts (1)
src/parser/index.ts (1)
parse(39-78)
src/parser/index.ts (1)
src/types/index.ts (1)
Token(73-78)
🪛 LanguageTool
.kiro/specs/extended-missing-value-tokenization/tasks.md
[grammar] ~35-~35: Use a hyphen to join words.
Context: ...hat .ab, .abc, .Abc produce single WORD tokens - **Validates: Requireme...
(QB_NEW_EN_HYPHEN)
.kiro/specs/stray-token-in-condition/design.md
[style] ~54-~54: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ies logical operators (&, |). 5. **New helper method `isValidAfterComparison()...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
.kiro/specs/stray-token-in-condition/requirements.md
[style] ~61-~61: Consider using a different verb for a more formal wording.
Context: ...or messages that help me understand and fix the problem. #### Acceptance Criteria ...
(FIX_RESOLVE)
🪛 markdownlint-cli2 (0.18.1)
.kiro/specs/extended-missing-value-tokenization/design.md
13-13: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
106-106: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
112-112: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
118-118: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
124-124: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
130-130: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
136-136: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
142-142: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Amazon Q Developer
🔇 Additional comments (23)
src/types/index.ts (1)
333-334: LGTM!The new error codes follow the sequential numbering pattern and integrate cleanly with the parser's stray-token and split-literal detection for conditions.
src/providers/diagnostics.ts (1)
383-383: LGTM!The range extension correctly includes the new parser error codes (3013 and 3014) introduced in this PR.
src/lexer/index.ts (2)
491-494: LGTM!The routing logic correctly identifies dot-letter patterns and directs them to the new handler. The placement after decimal number handling (lines 487-489) ensures
.5remains a NUMBER token.
1198-1234: LGTM! Solid implementation of extended missing value tokenization.The logic correctly handles all required cases:
- Lowercase single letters (
.a–.z) → NUMBER tokens- Uppercase single letters (
.A–.Z) → WORD tokens- Multi-letter sequences (
.ab,.a_something) → WORD tokensThe underscore check at line 1210 correctly ensures that patterns like
.a_are treated as multi-letter sequences rather than single-letter extended missing values, which aligns with the requirement that only.athrough.z(when followed by non-identifier characters) are valid extended missing values..kiro/specs/stray-token-in-condition/design.md (1)
1-234: Excellent design documentation.The design document is comprehensive and well-structured, with clear architecture decisions, a well-defined state machine, and testable correctness properties. The dual testing approach (unit + property tests) is appropriate for this feature.
.kiro/specs/extended-missing-value-tokenization/tasks.md (1)
1-81: Well-organized implementation plan.The task breakdown is logical with appropriate checkpoints and clear traceability to requirements. The completion of all tasks indicates thorough execution.
tests/property/extended-missing-value.property.test.ts (4)
26-56: LGTM: Whitespace separation test is correct.The property test correctly verifies that whitespace prevents extended missing value tokenization by checking that
. cproduces separate WORD tokens rather than a single NUMBER token.
65-79: LGTM: Decimal number test preserves backward compatibility.The test correctly verifies that decimal numbers like
.5continue to be tokenized as NUMBER tokens, ensuring backward compatibility.
89-121: LGTM: False positive prevention test is thorough.The test correctly verifies that extended missing values like
.ain expressions produce single NUMBER tokens and do not trigger split literal warnings. The additional check for split tokenization adds robustness.
127-149: LGTM: Additional edge case coverage.The unit-style tests provide concrete validation for system missing values and multi-digit decimal numbers, complementing the property-based tests well.
.kiro/specs/stray-token-in-condition/tasks.md (1)
1-128: Excellent implementation plan with refactoring.The task breakdown is comprehensive and well-organized. The inclusion of a refactoring step (Task 12) to extract shared state machine logic demonstrates good software engineering practices and code quality awareness.
tests/property/stray-token-detection.prop.test.ts (1)
40-43: Operator precedence concern is not applicable to this parser.The
parseExpression()method is a lexical/syntactic parser that collects tokens until reaching delimiters (commas, statement terminators, orif/inkeywords). It does not evaluate expressions or handle operator precedence—it simply tokenizes and validates structural properties like balanced parentheses. Including^alongside other arithmetic operators (+,-,*,/) in property-based testing is correct, as token detection does not depend on operator precedence semantics. The^operator is intentionally uniform with other arithmetic operators throughout the codebase (also present inexpression-token-handling.prop.test.tsandexpression-keyword-disambiguation.prop.test.ts).Likely an incorrect or invalid review comment.
pr-body.md (1)
1-27: LGTM!Clear and comprehensive PR documentation that accurately describes the new stray token detection feature, error codes, and test coverage.
.kiro/specs/stray-token-in-condition/requirements.md (1)
1-106: LGTM!Comprehensive requirements specification with clear user stories and acceptance criteria. The document covers all major scenarios including edge cases like split literals and multi-line continuations.
tests/unit/stray-token-detection.test.ts (4)
14-24: LGTM!Clean helper functions that encapsulate the lexer/parser setup and error filtering logic. The
get_errors_by_codehelper enables focused testing of specific error codes.
26-82: LGTM!Thorough coverage of basic stray token detection across all comparison operators (
==,!=,~=,<,>,<=,>=). Tests verify both error presence and message content.
84-134: LGTM!Excellent false-positive prevention tests. Coverage includes logical operators, arithmetic in comparisons, negation, nested parentheses, function calls, and proper handling of
inqualifier and options following conditions.
175-230: LGTM!Good coverage of split literal patterns including dot-space-number, dot-space-letter (extended missing values), number-space-dot, identifier-space-dot, and multi-line continuation scenarios.
src/parser/index.ts (5)
1484-1493: Verify~handling in isComparisonOperator.The comment mentions
~=may be tokenized as two separate tokens, and~alone is included. However, the state machine at lines 2311-2318 has special handling for~to avoid premature transition. This design seems intentional but worth confirming the behavior is correct when~is used as a standalone negation operator vs. part of~=.
1495-1553: LGTM!Well-implemented helper methods with comprehensive token classification.
isValidAfterComparisoncorrectly identifies all valid tokens that can follow a comparison expression, preventing false positives.
2217-2226: LGTM!Good design using a state stack to track expression parsing state at each parenthesis nesting level. This correctly handles nested expressions where each parenthesized sub-expression has its own state context.
2394-2443: LGTM!Comprehensive split literal detection covering all documented patterns:
. N,. a,N ., anda .. The implementation correctly handles the dot being tokenized as either OPERATOR or WORD depending on context.
2374-2382: LGTM!Clean delegation pattern with appropriate parameters for each qualifier type. The
ifqualifier correctly stops at theinkeyword and checks for empty expressions, while theinqualifier does not.Also applies to: 2445-2453
|
/q review changes |
|
@coderabbitai review changes |
|
I've reviewed the changes in this PR that implements extended missing value tokenization for Stata. The implementation looks solid and addresses the false positive "split literal" diagnostics effectively. Here are my observations: StrengthsWell-designed solution: The lexer modification correctly handles the root cause by tokenizing Comprehensive implementation: The
Excellent test coverage: The property-based tests validate the correctness properties across all inputs and ensure backward compatibility is maintained. Clean integration: The changes are well-integrated into the existing lexer flow without disrupting other functionality like decimal number parsing ( Minor ObservationsThe implementation correctly preserves existing behavior for decimal numbers and system missing values while adding the new extended missing value functionality. The ordering of checks in The comprehensive documentation and property-based testing approach demonstrates good software engineering practices. All 2861 tests passing indicates the changes don't introduce regressions. This is a well-executed fix that addresses the specific issue while maintaining backward compatibility and following good coding practices. |
|
@jbearak: I'll review the changes in this PR. ✅ Actions performedReview triggered.
|
Address all review comments from CodeRabbit, Amazon Q Developer, and Claude: 1. Amazon Q Developer (lines 462-465): Fixed logic error in command node if qualifier context detection - Added range check to verify operator is actually within the if qualifier range - Previously returned 'qualifier' for ANY operator in a command with ifExpression 2. Claude issue #2: Added missing while condition check - Added condition check for while nodes to properly classify C-style operators in while conditions - Now returns 'control_flow' context when operator is in while condition 3. Claude issue #3: Fixed incorrect classification of operators in body commands - Added body range check before falling through to condition check - Prevents operators in plain body commands from being incorrectly classified as 'control_flow' - Applied fix to both if/else nodes and foreach/forvalues/while/frame nodes 4. Claude issue #1: Removed unnecessary 'as' type casts - Removed 'as' casts from command and program nodes - TypeScript automatically narrows types after type checks 5. CodeRabbit issues: Fixed markdown formatting - Added language specifiers to fenced code blocks in design.md (typescript, markdown, text) - Verified pipe characters already escaped in README.md - Verified test config already has cStyleLogicalInControlFlow setting All 85 operator sequence tests pass.
…rows as written, and read abbreviated weights and foreach list types in parse --json
Formatter (both modes unless noted):
- An inline python:/mata: statement whose string holds a ; before a
comment marker ("a;\t//b") comes back byte for byte. Only a ; that
ends the statement (a #delimit ; terminator, or a ; before ///) is
kept outside the placeholder.
- Under #delimit ;, a /// after the ; that ends a statement no longer
makes the next statement a continuation line, so one format reaches
the fixed point and the indentation diagnostic agrees.
- AST mode prints option arguments as written instead of respacing
them as expressions, which turned using(plugins/my.plugin) into
using(plugins / my.plugin), format(%9.0g) into format(9.0g), eq(#2)
into eq(2) and c:\data\x.gph into c : data x.gph.
- AST mode keeps the () of a call with no arguments (display
runiform()) and a blank data row between input and end.
- Embedded-block placeholders are applied in one pass with line
offsets computed once (1,000 mata: lines: 11.3 ms to 2.3 ms for
indentation diagnostics).
sight parse --json:
- Weight words and abbreviations Stata 18 accepts: w..weight,
fw..fweight, freq..frequency, aw..aweight, cell..cellsize,
pw..pweight, iw..iweight.
- foreach ... of var/new/num/loc/glo (three letters or more) report the
full list type.
- else /* c */ if reports else_if: true.
- syntax Level(integer 95) reports default "95"; hover shows it as
Level(integer 95).
- display runiform() reports runiform() as its argument.
…ritten when formatting, and read abbreviated weights and foreach list types in parse --json (#419) * Keep embedded strings, option arguments, call parens and blank input rows as written, and read abbreviated weights and foreach list types in parse --json Formatter (both modes unless noted): - An inline python:/mata: statement whose string holds a ; before a comment marker ("a;\t//b") comes back byte for byte. Only a ; that ends the statement (a #delimit ; terminator, or a ; before ///) is kept outside the placeholder. - Under #delimit ;, a /// after the ; that ends a statement no longer makes the next statement a continuation line, so one format reaches the fixed point and the indentation diagnostic agrees. - AST mode prints option arguments as written instead of respacing them as expressions, which turned using(plugins/my.plugin) into using(plugins / my.plugin), format(%9.0g) into format(9.0g), eq(#2) into eq(2) and c:\data\x.gph into c : data x.gph. - AST mode keeps the () of a call with no arguments (display runiform()) and a blank data row between input and end. - Embedded-block placeholders are applied in one pass with line offsets computed once (1,000 mata: lines: 11.3 ms to 2.3 ms for indentation diagnostics). sight parse --json: - Weight words and abbreviations Stata 18 accepts: w..weight, fw..fweight, freq..frequency, aw..aweight, cell..cellsize, pw..pweight, iw..iweight. - foreach ... of var/new/num/loc/glo (three letters or more) report the full list type. - else /* c */ if reports else_if: true. - syntax Level(integer 95) reports default "95"; hover shows it as Level(integer 95). - display runiform() reports runiform() as its argument. * Parse include using/…, program `name', glued using and price[`weight'] as Stata does, and keep label/note text and program-header comments when formatting (#417) Fixes parser regressions since v0.15.1, each checked against StataMP 18: - include/do/run using/setup.do takes the path, not the using keyword - program `cmdname' defines a program closed by its end - #delimit ; program // note, then define p; defines p - `stem'using, `stem'in and `stem'if are one name - price[`weight'] is a subscript, not a weight clause - label variable/data/define, char and note ...: text keeps its if/in/using words, and AST formatting prints it as written - a comment in a program header, or a /// note before an inline mata:, makes AST formatting leave the file as written instead of dropping it - a run of // comments in a #delimit ; statement parses in linear time * Keep Stata console sends from being lost at --more--, while connecting, or behind a long command, and keep polling after a huge burst of output (#416) * Keep the Stata console polling after a huge burst of output, and keep editor sends from being lost at --more--, while connecting, or behind a long command - Automation backend: append a poll's lines without spreading them (a burst of ~200k lines overflowed the stack and stopped polling for good), consume held lines by index, and keep polling after a poll throws, saying so once. - Editor sends go through a new send_line entry (console API v3): at --more-- they wait for the prompt instead of being taken as pager keys; typed keys still answer --more--. - A Stata pane holds each typed send's temp file until its console gives the line to Stata, then deletes it after the usual delay; it deletes it at once if the line is dropped or the pane ends. - The active-terminal commands send to a Stata pane through its queue, so a send made while the pane connects isn't dropped. * Don't let a hand-off's cleanup delete a send's file soon after the pane releases it * Read input data, prefixed mata: and python: openers, and #delimit ; star comments as Stata does (#414) * Read input data, prefixed embedded openers, and #delimit ; star comments as Stata does Co-Authored-By: Claude Opus 5.5 <[email protected]> * Bound the program-header check to the input data region Co-Authored-By: Claude Opus 5.5 <[email protected]> * Test formatting of prefixed mata: lines and #delimit ; input records Co-Authored-By: Claude Opus 5.5 <[email protected]> * Test a * comment after an abbreviated #d ; Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> * Print no stray ; for an input with no records under #delimit ; The blank-row check compared line numbers, which under #delimit ; is true for an empty block because the data starts on the input line. Caught by input-data-edge-cases.test.ts once main's #414 was merged in. --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Fixes false positive "split literal" diagnostics for Stata extended missing values (
.athrough.z).Problem
The lexer was tokenizing
.aas two separate tokens (.as WORD andaas WORD), which triggered the parser's split literal detection to incorrectly warn about code likeif x == .a.Solution
Added
scanExtendedMissingOrWord()method to the lexer that handles dot followed by letter(s):.athrough.z(lowercase single letter) →NUMBERtoken (valid extended missing).Athrough.Z(uppercase single letter) →WORDtoken (invalid in Stata).ab,.abc, etc. (multi-letter) → singleWORDtoken (invalid)Testing
Added property-based tests covering:
.a-.zproduce NUMBER tokens.A-.Zproduce WORD tokens. a→ two tokens).5) still work correctlyAll 2861 tests pass.
Summary by CodeRabbit
Release Notes
New Features
if x == y oops).Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.