import { StreamLanguage } from '@codemirror/language';
import type { ProjectEditorLanguageId } from '../project-language';
import { simpleParser, wordSet } from './common';

const cLike = simpleParser({ keywords: wordSet('alignas alignof asm auto break case const continue default do else enum extern for goto if inline register restrict return sizeof static struct switch typedef union volatile while class namespace new delete template this throw try catch public private protected virtual override using constexpr nullptr'), types: wordSet('void char short int long float double signed unsigned bool size_t string wchar_t'), lineComment: '//', blockComment: ['/*','*/'], hashComment: true });
const java = simpleParser({ keywords: wordSet('abstract assert boolean break byte case catch char class const continue default do double else enum extends final finally float for goto if implements import instanceof int interface long native new package private protected public return short static strictfp super switch synchronized this throw throws transient try void volatile while record sealed permits var'), types: wordSet('String Integer Long Double Float Boolean Object List Map Set Optional'), lineComment: '//', blockComment: ['/*','*/'] });
const rust = simpleParser({ keywords: wordSet('as async await break const continue crate dyn else enum extern false fn for if impl in let loop match mod move mut pub ref return self Self static struct super trait true type unsafe use where while'), types: wordSet('bool char str i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize f32 f64 String Vec Option Result Box'), lineComment: '//', blockComment: ['/*','*/'] });
const go = simpleParser({ keywords: wordSet('break default func interface select case defer go map struct chan else goto package switch const fallthrough if range type continue for import return var'), types: wordSet('bool byte complex64 complex128 error float32 float64 int int8 int16 int32 int64 rune string uint uint8 uint16 uint32 uint64 uintptr'), lineComment: '//', blockComment: ['/*','*/'] });

export function projectCompiledLanguage(id: ProjectEditorLanguageId) {
  return StreamLanguage.define(id === 'java' ? java : id === 'rust' ? rust : id === 'go' ? go : cLike);
}
