module author Paolo Masci
 *  date copyright import { PvsParser , ParserDiagnostics } from './pvs-parser/javaTarget/pvsParser' ; import { DdlParser } from './ddl-parser/javaTarget/ddlParser' ; import * as path from 'path' ; import { FileDescriptor } from '../common/serverInterface' ; import { Diagnostic } from 'vscode-languageserver' ; export type AntlrTarget = "js" | "java" ; export class Parser { protected pvsParser = new PvsParser ( ) ; protected ddlParser = new DdlParser ( ) ; param desc async parseFile ( desc , opt ? ) { if ( desc ) { opt = opt || { } ; switch ( desc . fileExtension ) { case ".pvs" : { return ; await this . pvsParser . parseFile ( desc ) ; } case ".hpvs" : { return await this . ddlParser . parseFile ( desc ) ; } default : { console . error ( `[parser.parseFile] Error: unrecognized extension ${ desc . fileExtension }` ) ; } } } return null ; } async hp2pvs ( desc ) { if ( desc ) { if ( desc . fileExtension === ".hpvs" ) { const ofname = path . join ( desc . contextFolder , `${ desc . fileName }.pvs` ) ; return await this . ddlParser . parseFile ( desc , { output : `${ ofname }` } ) ; } } return null ; } async prettyPrintDdl ( desc ) { if ( desc && desc . expr ) { return await this . ddlParser . prettyPrint ( desc ) ; } return "" ; } killParser ( ) { if ( this . pvsParser ) { this . pvsParser . stop ( ) ; } } }