diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index dfe0770..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/.gitignore b/.gitignore index a14702c..2486e5a 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json # Finder (MacOS) folder config .DS_Store + +/tmp \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index b5a267e..a9564d0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,107 +1,261 @@ -I am using the lezer grammar [System Guide](https://lezer.codemirror.net/docs/guide/) [api](https://lezer.codemirror.net/docs/ref/). +# CLAUDE.md -Default to using Bun instead of Node.js. +This file provides guidance to Claude Code (claude.ai/code) when working with the Shrimp programming language. -- Use `bun ` instead of `node ` or `ts-node ` -- Use `bun test` instead of `jest` or `vitest` -- Use `bun build ` instead of `webpack` or `esbuild` -- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install` -- Use `bun run - - +### Common Grammar Gotchas + +**EOF infinite loops**: Using `@eof` in repeating patterns can match EOF multiple times. Current approach uses explicit statement/newline alternatives. + +**Token precedence**: Use `@precedence` to resolve conflicts between similar tokens. + +**External tokenizers**: Custom logic in `tokenizers.ts` handles complex cases like identifier vs word distinction. + +**Empty line parsing**: The grammar structure `(statement | newlineOrSemicolon)+ eof?` allows proper empty line and EOF handling. + +## Testing Strategy + +### Parser Tests (`src/parser/parser.test.ts`) + +- **Token types**: Identifier vs Word distinction +- **Function calls**: With and without arguments +- **Expressions**: Binary operations, parentheses, precedence +- **Functions**: Single-line and multiline definitions +- **Whitespace**: Empty lines, mixed delimiters +- **Edge cases**: Ambiguous parsing, incomplete input + +Test structure: + +```typescript +describe('feature area', () => { + test('specific case', () => { + expect(input).toMatchTree(expectedCST) + }) +}) ``` -With the following `frontend.tsx`: +When adding language features: -```tsx#frontend.tsx -import React from "react"; +1. Write grammar tests first showing expected CST structure +2. Update grammar rules to make tests pass +3. Add integration tests showing real usage +4. Test edge cases and error conditions -// import .css files directly and it works -import './index.css'; +## Bun Usage -import { createRoot } from "react-dom/client"; +Default to Bun over Node.js/npm: -const root = createRoot(document.body); +- Use `bun ` instead of `node ` or `ts-node ` +- Use `bun test` instead of `jest` or `vitest` +- Use `bun install` instead of `npm install` +- Use `bun run