@adaycuestacorrea/lexer-generator-solution
v4.2.2
Published
A package that can generate basic lexical analyzers
Downloads
22
Readme
Lexer Generator Lab
- Author: Aday Cuesta Correa
- Email: [email protected]
- npm i @adaycuestacorrea/lexer-generator-solution
https://ull-esit-gradoii-pl.github.io/practicas/lexer-generator.html
Rúbrica
El paquete está publicado en GitHub Registry y se instala correctamente
El módulo exporta los generadores léxicos y funcionan correctamente
El manejo de errores con el token ERROR es correcto
Manejo de "tokens skip"
if (!validTokens.get(type).skip) {
let value = match.groups[type];
if (validTokens.get(type).value) value = validTokens.get(type).value(value);
result.push({type, value, line, col, length: regexp.lastIndex - start});
}
Contiene tests comprobando el atributo de transformación value
test('Assignment to string', () => {
const str = 'const varName = "value"';
const result = lexer(str);
const expected = [
{
type: 'RESERVEDWORD',
value: 'const',
col: 1,
line: 1,
length: 5,
},
{
type: 'ID',
value: 'varName',
col: 7,
line: 1,
length: 7,
},
{
type: 'OP',
value: '=',
col: 15,
line: 1,
length: 1,
},
{
type: 'STRING',
value: '"value"',
col: 17,
line: 1,
length: 7,
},
];
expect(result).toEqual(expected);
});