test: comprehensive grammar and logic tests#47
Conversation
6가지 테스트: 덧셈, 곱셈 우선순위(STAR>PLUS), 좌결합 뺄셈 체인, 정수 나눗셈, 괄호 우선순위 오버라이드, 동일 우선순위 혼합 체인. eval_c()로 실제 정수 값을 계산하여 검증. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
precedence=0 토큰들이 S/R 충돌 시 symbol.associative=="left" (기본값) 조건이 True가 되어 reduce 우선 → 좌결합 트리 생성. 기존 test_shift_reduce_resolution_prefers_shift는 체인 케이스 없음. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
S/R 충돌에서 기본 reduce 동작으로 인해 else가 inner if가 아닌 outer if에 바인딩됨. C/Java 관례(inner if가 else를 가져야 함)와 다름. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
PLUS(1) < STAR(2) < UMINUS_UP(3) 우선순위 계층. prec_token 오버라이드로 단항 마이너스가 곱셈보다 강하게 바인딩됨을 검증. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
빈 리스트, 단일 요소, 3개 요소 케이스를 right-recursive 문법으로 검증. items 값 리스트를 직접 비교하여 파싱 정확성 확인. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
인수 없음/1개/3개 함수 호출 케이스. ID_F, LPAREN_F, RPAREN_F, COMMA_F, NUM_F 토큰 사용. 기존 테스트에 없는 함수 호출 구문 문법을 처음으로 검증. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
100단계 중첩 괄호를 스택 오버플로 없이 파싱함을 검증. LR 스택은 Python 리스트(명시적)라 재귀 한계 무관. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
줄바꿈을 포함한 소스에서 각 토큰의 lineno/offset 정확성 검증. CALC_LEXER로 렉싱 후 파싱까지 통합 테스트. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
괄호 미닫힘 및 여분 토큰 시 ParsingError 발생 검증. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
program → stmts → stmt stmts | ε 두 단계 문법. 빈 입력, 1개, 3개 구문 케이스 및 순서 보존 검증. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter PYTHON_BLACK |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter PYTHON_BLACK |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter PYTHON_BLACK |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter PYTHON_BLACK |
- Use Sequence (covariant) instead of list (invariant) for the RHS symbol sequence in Parser.__init__ grammar parameter type, resolving list variance errors when passing subclass token lists - Add GrammarDict[T] type alias and annotate grammar dicts with concrete AST node types so Parser[T] is inferred correctly - Add isinstance(result, ExprC) narrowing before eval_c() calls where parse() return type is ExprC | Token Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
- Change grammar parameter type from dict to Mapping (covariant in value), fixing invariance errors when existing Grammar/GrammarRules type aliases (using list) are passed from other test files - Add Sequence wrapper around the productions list for the same reason - Convert right (now Sequence) to list() internally to preserve the list[Symbol] contract expected by Rule and Item Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
Pytest ReportTest Results
Comment by ✨sambyeol/publish-pytest-action |
Pytest ReportTest Results
Comment by ✨sambyeol/publish-pytest-action |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
Summary
tests/test_grammar_logic.pywith 23 tests (22 passing, 1 xfail) across 10 sections covering grammar patterns and parser logic not exercised by the existing test suite.What's tested
*>+), left-assoc subtraction chain, integer division, parentheses override, mixed same-precedence chain — all verified by evaluating to actual integer valuestest_shift_reduce_resolution_prefers_shiftonly tests the two-token case with no tree-shape assertionif c1 then if c2 then s1 else s2: Plare bindselseto the outerifdue to the default reduce-wins behavior; most languages (C, Java) expect the innerifto absorb it%precPLUS(1) < STAR(2) < UMINUS(3)hierarchy; verifies+and*in the same grammar as unary minus with aprec_tokenoverride