Skip to content

Commit

Permalink
bug fix in type keyword searching, fromConfig export
Browse files Browse the repository at this point in the history
  • Loading branch information
Seva D committed Jan 8, 2024
1 parent 71117eb commit 8a334da
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { parseInput } from './parser.js';
import { traverseResult } from './visitor.js';
import { createMany } from './createStruct.js';
import { createMany, create } from './createStruct.js';
import { currentArch } from './currentArch.js';

export function compile(str, arch = currentArch, BufferImpl = Buffer) {
return createMany(traverseResult(parseInput(str).cstOutput), arch, BufferImpl);
}

export function fromConfig(config, arch = currentArch, BufferImpl = Buffer) {
return create(config, arch, BufferImpl);
}
7 changes: 6 additions & 1 deletion src/trie.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ export class Trie {
i = skipWhitespace(text, i) - 1;
}
if (current.isEnd) {
res = [text.slice(startOffset, i + 1)];
if (i < text.length - 1 && /\w/.test(text[i + 1])) {
continue;
}
else {
res = [text.slice(startOffset, i + 1)];
}
}
}
return res;
Expand Down
2 changes: 1 addition & 1 deletion test/dataTypes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test('matchType', (t) => {
assert.deepEqual(matchType('unsigned long', 0), ['unsigned long']);
assert.deepEqual(matchType('uint32_t', 0), ['uint32_t']);

const withPadding = 'AAAAAAAAAAAA unsigned \n\nlong longAAAAAAAA';
const withPadding = 'AAAAAAAAAAAA unsigned \n\nlong long AAAAAAAA';
assert.deepEqual(matchType(withPadding, withPadding.indexOf('u')), ['unsigned \n\nlong long']);

assert.deepEqual(matchType('uint;32_t'), null);
Expand Down

0 comments on commit 8a334da

Please sign in to comment.