-
Notifications
You must be signed in to change notification settings - Fork 40
Anotando colunas inicial e final para lexemas encontrados pelo Lexador. #1093
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,7 +85,10 @@ export class LexadorCalango implements LexadorInterface<SimboloInterface> { | |
| } | ||
| adicionarSimbolo(tipo: any, literal?: any): void { | ||
| const texto = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual); | ||
| this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha, -1)); | ||
| const comprimento = Math.max(texto.length, 1); | ||
| const colunaInicio = this.inicioSimbolo + 1; | ||
| const colunaFim = this.inicioSimbolo + comprimento; | ||
| this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha, -1, colunaInicio, colunaFim)); | ||
|
Comment on lines
86
to
+91
|
||
| } | ||
|
|
||
| simboloAtual(): string { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,8 +88,13 @@ export class LexadorPortugolIpt implements LexadorInterface<SimboloInterface> { | |
|
|
||
| adicionarSimbolo(tipo: any, literal?: any): void { | ||
| const texto: string = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual); | ||
| const lexema = literal || texto; | ||
| const comprimentoLexema = typeof lexema === 'string' ? lexema.length : 0; | ||
| const comprimento = Math.max(comprimentoLexema, texto.length) || 1; | ||
| const colunaInicio = this.inicioSimbolo + 1; | ||
| const colunaFim = this.inicioSimbolo + comprimento; | ||
| this.simbolos.push( | ||
| new Simbolo(tipo, literal || texto, literal, this.linha + 1, this.hashArquivo) | ||
| new Simbolo(tipo, lexema, literal, this.linha + 1, this.hashArquivo, colunaInicio, colunaFim) | ||
| ); | ||
|
Comment on lines
89
to
98
|
||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,7 +110,10 @@ export class LexadorPrisma implements LexadorInterface<SimboloInterface> { | |
|
|
||
| adicionarSimbolo(tipo: string, literal: any = null): void { | ||
| const texto: string = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual); | ||
| this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha + 1, this.hashArquivo)); | ||
| const comprimento = Math.max(texto.length, 1); | ||
| const colunaInicio = this.inicioSimbolo + 1; | ||
| const colunaFim = this.inicioSimbolo + comprimento; | ||
| this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha + 1, this.hashArquivo, colunaInicio, colunaFim)); | ||
|
Comment on lines
111
to
+116
|
||
| } | ||
|
|
||
| analisarTexto(delimitador: string = '"'): void { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,7 +121,10 @@ export class LexadorTenda implements LexadorInterface<SimboloInterface> { | |
|
|
||
| adicionarSimbolo(tipo: any, literal: any = null): void { | ||
| const texto: string = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual); | ||
| this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha + 1, this.hashArquivo)); | ||
| const comprimento = Math.max(texto.length, 1); | ||
| const colunaInicio = this.inicioSimbolo + 1; | ||
| const colunaFim = this.inicioSimbolo + comprimento; | ||
| this.simbolos.push(new Simbolo(tipo, texto, literal, this.linha + 1, this.hashArquivo, colunaInicio, colunaFim)); | ||
| } | ||
|
Comment on lines
122
to
128
|
||
|
|
||
| simboloAtual(): string { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,13 +6,17 @@ export class Simbolo implements SimboloInterface { | |
| literal: any; | ||
| linha: number; | ||
| hashArquivo: number; | ||
| colunaInicio: number; | ||
| colunaFim: number; | ||
|
Comment on lines
+9
to
+10
|
||
|
|
||
| constructor(tipo: string, lexema: string, literal: any, linha: number, hashArquivo: number) { | ||
| constructor(tipo: string, lexema: string, literal: any, linha: number, hashArquivo: number, colunaInicio: number = 0, colunaFim: number = 0) { | ||
| this.tipo = tipo; | ||
| this.lexema = lexema; | ||
| this.literal = literal; | ||
| this.linha = linha; | ||
| this.hashArquivo = hashArquivo; | ||
| this.colunaInicio = colunaInicio; | ||
| this.colunaFim = colunaFim; | ||
| } | ||
|
|
||
| paraTexto(): string { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the Simbolo class always provides colunaInicio and colunaFim values (defaulting to 0), the SimboloInterface declares them as optional. This creates a type mismatch when assigning these potentially undefined values to CorrecaoSugeridaInterface, which requires non-optional number values. Consider using the nullish coalescing operator to provide a fallback value:
colunaInicio: declaracao.simbolo.colunaInicio ?? 0andcolunaFim: declaracao.simbolo.colunaFim ?? 0.