diff options
author | partouf <partouf@gmail.com> | 2023-05-16 01:20:49 +0200 |
---|---|---|
committer | partouf <partouf@gmail.com> | 2023-05-16 01:20:49 +0200 |
commit | 7e9356ad53a858a09eed39dc5faa1cb0d55a78a0 (patch) | |
tree | 5abaa4584e01dcd23e8093295bee3fa11945dade | |
parent | 3b350bcee57d1bceac738bcad7e39dd37ed0cd68 (diff) | |
download | compiler-explorer-gh-7399.tar.gz compiler-explorer-gh-7399.zip |
fix haskell/ghc argparsergh-7399
-rw-r--r-- | compiler-args-app.ts | 1 | ||||
-rw-r--r-- | lib/compilers/argument-parsers.ts | 19 | ||||
-rw-r--r-- | lib/compilers/haskell.ts | 6 |
3 files changed, 23 insertions, 3 deletions
diff --git a/compiler-args-app.ts b/compiler-args-app.ts index 9392f226c..c743e7db2 100644 --- a/compiler-args-app.ts +++ b/compiler-args-app.ts @@ -62,6 +62,7 @@ const compilerParsers = { turboc: Parsers.TurboCParser, toit: Parsers.ToitParser, circle: Parsers.CircleParser, + ghc: Parsers.GHCParser, }; class CompilerArgsApp { diff --git a/lib/compilers/argument-parsers.ts b/lib/compilers/argument-parsers.ts index 414d29880..9593f2376 100644 --- a/lib/compilers/argument-parsers.ts +++ b/lib/compilers/argument-parsers.ts @@ -950,3 +950,22 @@ export class FlangParser extends ClangParser { return possible; } } + +export class GHCParser extends GCCParser { + static override async parse(compiler) { + const results = await Promise.all([this.getOptions(compiler, '--help')]); + const options = Object.assign({}, ...results); + await this.setCompilerSettingsFromOptions(compiler, options); + return compiler; + } + + static override async getOptions(compiler, helpArg) { + const optionFinder1 = /^ {4}(-[\w[\]]+)\s+(.*)/i; + const optionFinder2 = /^ {4}(-[\w[\]]+)/; + const result = await compiler.execCompilerCached(compiler.compiler.exe, helpArg.split(' ')); + const options = result.code === 0 ? this.parseLines(result.stdout, optionFinder1, optionFinder2) : {}; + + compiler.possibleArguments.populateOptions(options); + return options; + } +} diff --git a/lib/compilers/haskell.ts b/lib/compilers/haskell.ts index 4446127e7..de5f054d8 100644 --- a/lib/compilers/haskell.ts +++ b/lib/compilers/haskell.ts @@ -28,7 +28,7 @@ import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; import {BaseCompiler} from '../base-compiler.js'; -import {ClangParser} from './argument-parsers.js'; +import {GHCParser} from './argument-parsers.js'; export class HaskellCompiler extends BaseCompiler { static get key() { @@ -76,7 +76,7 @@ export class HaskellCompiler extends BaseCompiler { return [libPathFlag + '.', ...this.getSharedLibraryPaths(libraries).map(path => libPathFlag + path)]; } - override getArgumentParser() { - return ClangParser; + override getArgumentParser(): any { + return GHCParser; } } |