An open API service indexing awesome lists of open source software.

https://github.com/totvs/tds-parsers

Extensão para análise sintática das linguagens proprietárias TOTVS.
https://github.com/totvs/tds-parsers

parsers

Last synced: about 1 year ago
JSON representation

Extensão para análise sintática das linguagens proprietárias TOTVS.

Awesome Lists containing this project

README

          

# TOTVS Developer Studio: Analisador sintático

[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)

## Instalação

Para uso local:

```
npm install @totvs/tds-parsers
```

Para uso global:

```
npm install @totvs/tds-parsers -g
```

## Uso embarcado (API)

Se você deseja executar o **TDS-Parsers** via programa:

Importe o pacote

```ts
import { parser } from '@totvs/tds-parsers';
import { IParserOptions } from '@totvs/tds-parsers/typings/config';
import { ASTNode } from '@totvs/tds-parsers/typings/ast_node';
```

## `parser(source: string, parserInfo: IParserInfo): { ast: ASTNode~, error: Error }`

`parser` executa a análise sintática do conteúdo em `source`, retornando a arvore sintátîca abstrata (_AST_, em ingles). `parserInfo.parser` deve ser informado de acordo com a linguagem a ser formatada. Os valores válidos são: `advpl` ou `4gl`. As demais informações são opcionais.

```ts
try {
const parserInfo: any = {
debug: false, //adiciona informações de depuração do analisador
filepath: "c:\\myProject\\file1.prw", //localização do arquivo
parser: "advpl", //analisador a ser aplicado
fileext: "prw", //extensão do arquivo a ser considerado
};

const result: any = parser(source, parserInfo);
if (result.error) {
throw result.error;
}

// processamento da AST aqui

} catch (error) {
if (error.location) {
console.error(
`Sintax error: [${error.location.start.line}:${error.location.start.column}] ${error.message}`
);
} else {
console.error(error);
}
throw error;
}
}
```

## Mantenedor



TOTVS S.A.

🚧 🔌 📆

## Colaboradores



Alan Cândido

💻 📖 ⚠️