Skip to content
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

Rename "delimeter" to "delimiter" #1663

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/langium/src/parser/indentation-aware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export interface IndentationTokenBuilderOptions<TerminalName extends string = st
*
* @default []
*/
ignoreIndentationDelimeters: Array<IndentationAwareDelimiter<TerminalName | KeywordName>>
ignoreIndentationDelimiters: Array<IndentationAwareDelimiter<TerminalName | KeywordName>>
}

export const indentationBuilderDefaultOptions: IndentationTokenBuilderOptions = {
indentTokenName: 'INDENT',
dedentTokenName: 'DEDENT',
whitespaceTokenName: 'WS',
ignoreIndentationDelimeters: [],
ignoreIndentationDelimiters: [],
};

export enum LexingMode {
Expand Down Expand Up @@ -129,7 +129,7 @@ export class IndentationAwareTokenBuilder<Terminals extends string = string, Key
throw new Error('Invalid tokens built by default builder');
}

const { indentTokenName, dedentTokenName, whitespaceTokenName, ignoreIndentationDelimeters } = this.options;
const { indentTokenName, dedentTokenName, whitespaceTokenName, ignoreIndentationDelimiters } = this.options;

// Rearrange tokens because whitespace (which is ignored) goes to the beginning by default, consuming indentation as well
// Order should be: dedent, indent, spaces
Expand All @@ -138,7 +138,7 @@ export class IndentationAwareTokenBuilder<Terminals extends string = string, Key
let ws: TokenType | undefined;
const otherTokens: TokenType[] = [];
for (const tokenType of tokenTypes) {
for (const [begin, end] of ignoreIndentationDelimeters) {
for (const [begin, end] of ignoreIndentationDelimiters) {
if (tokenType.name === begin) {
tokenType.PUSH_MODE = LexingMode.IGNORE_INDENTATION;
} else if (tokenType.name === end) {
Expand All @@ -159,7 +159,7 @@ export class IndentationAwareTokenBuilder<Terminals extends string = string, Key
throw new Error('Some indentation/whitespace tokens not found!');
}

if (ignoreIndentationDelimeters.length > 0) {
if (ignoreIndentationDelimiters.length > 0) {
const multiModeLexerDef: IMultiModeLexerDefinition = {
modes: {
[LexingMode.REGULAR]: [dedent, indent, ...otherTokens, ws],
Expand Down
8 changes: 4 additions & 4 deletions packages/langium/test/parser/indentation-aware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ describe('IndentationAwareLexer', () => {

});

describe('IndentationAwareTokenBuilder#ignoreIndentationDelimeters', async () => {
describe('IndentationAwareTokenBuilder#ignoreIndentationDelimiters', async () => {

const grammar = `
grammar PythonIfWithLists
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('IndentationAwareTokenBuilder#ignoreIndentationDelimeters', async () =>
`;

const lexer = await getLexer(grammar, {
ignoreIndentationDelimeters: [
ignoreIndentationDelimiters: [
['(', ')'],
['[', ']'],
],
Expand All @@ -248,7 +248,7 @@ describe('IndentationAwareTokenBuilder#ignoreIndentationDelimeters', async () =>
expect(errors).toHaveLength(0);
});

test('should ignore indentation inside the given delimeters', async () => {
test('should ignore indentation inside the given delimiters', async () => {
const { errors, tokens } = lexer.tokenize(expandToString`
return [
false,
Expand All @@ -267,7 +267,7 @@ describe('IndentationAwareTokenBuilder#ignoreIndentationDelimeters', async () =>
expect(tokenNames).not.toContain('DEDENT');
});

test('should handle nested delimeters', async () => {
test('should handle nested delimiters', async () => {
const { errors, tokens } = lexer.tokenize(expandToString`
return [
[
Expand Down
Loading