-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move Lexer to lexer-core package
- Loading branch information
1 parent
9cb4415
commit c308cb1
Showing
22 changed files
with
324 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
nodejs-tools/nodejs-compiler-tools/formatter-xml/src/test_utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
...ejs-compiler-tools/lexer-xml/src/Lexer.ts → ...js-compiler-tools/lexer-core/src/Lexer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export * from './Lexer'; | ||
export * from './LexerError'; | ||
export * from './LexerInput'; | ||
export * from './LexerInputReader'; | ||
|
||
export * from './tokens'; | ||
export * from './utils'; |
24 changes: 24 additions & 0 deletions
24
nodejs-tools/nodejs-compiler-tools/lexer-core/src/tokens.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { test, expect } from 'vitest'; | ||
|
||
import { cloneToken, Token } from './tokens'; | ||
|
||
test('should clone token', () => { | ||
const token: Token<'dummy_token_type'> = { | ||
lineNumber: 43, | ||
columnNumber: 25, | ||
tokenLiteral: 'dummy token literal', | ||
tokenType: 'dummy_token_type', | ||
}; | ||
|
||
const clonedToken = cloneToken(token); | ||
|
||
// reference equality | ||
expect(clonedToken).not.toBe(token); | ||
// value equality | ||
expect(clonedToken).toStrictEqual({ | ||
lineNumber: 43, | ||
columnNumber: 25, | ||
tokenLiteral: 'dummy token literal', | ||
tokenType: 'dummy_token_type', | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
nodejs-tools/nodejs-compiler-tools/lexer-core/src/tokens.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export type Token<T> = { | ||
tokenType: T; | ||
tokenLiteral: string; | ||
lineNumber: number; | ||
columnNumber: number; | ||
}; | ||
|
||
export function cloneToken<T>(token: Token<T>): Token<T> { | ||
return { ...token }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,2 @@ | ||
export { XmlLexer } from './Lexer'; | ||
export { nextToken } from './nextToken'; | ||
export { | ||
type Token, | ||
TokenTypes, | ||
cloneToken, | ||
TokenType, | ||
serializeToken, | ||
type SerializedToken, | ||
type SerializedTokenType, | ||
} from './tokens'; | ||
export { XmlTokenType } from './tokens'; |
Oops, something went wrong.