|
@@ -5,7 +5,8 @@ import { SourceInfo } from './sourceInfo';
|
|
|
import { Types, toInt, toString } from './types';
|
|
|
import { convertFromString } from './operators';
|
|
|
import { SyntaxErrorFactory } from './error/syntaxErrorFactory';
|
|
|
-import { NAMES } from './../processor/definedFunctions';
|
|
|
+import { LanguageDefinedFunction } from './../processor/definedFunctions';
|
|
|
+import { LanguageService } from '../services/languageService';
|
|
|
|
|
|
export class IVProgParser {
|
|
|
|
|
@@ -38,6 +39,7 @@ export class IVProgParser {
|
|
|
this.functionTypes = this.variableTypes.concat(this.lexerClass.RK_VOID);
|
|
|
this.parsingArrayDimension = 0;
|
|
|
this.scope = [];
|
|
|
+ this.langFuncs = LanguageService.getCurrentLangFuncs();
|
|
|
}
|
|
|
|
|
|
parseTree () {
|
|
@@ -427,7 +429,7 @@ export class IVProgParser {
|
|
|
const func = new Commands.Function(functionID, returnType, formalParams, commandsBlock);
|
|
|
if (functionID === null && !func.isMain) {
|
|
|
// TODO: better error message
|
|
|
- throw SyntaxErrorFactory.invalid_main_return(this.lexerClass.MAIN_FUNCTION_NAME,
|
|
|
+ throw SyntaxErrorFactory.invalid_main_return(LanguageDefinedFunction.getMainFunctionName(),
|
|
|
this.lexer.literalNames[this.lexerClass.RK_VOID],
|
|
|
token.line);
|
|
|
}
|
|
@@ -474,7 +476,7 @@ export class IVProgParser {
|
|
|
}
|
|
|
this.pos++;
|
|
|
if (this.insideScope(IVProgParser.FUNCTION)) {
|
|
|
- if (token.text === this.lexerClass.MAIN_FUNCTION_NAME){
|
|
|
+ if (token.text === LanguageDefinedFunction.getMainFunctionName()){
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@@ -979,12 +981,15 @@ export class IVProgParser {
|
|
|
}
|
|
|
|
|
|
getFunctionName (id) {
|
|
|
- if (id === this.lexerClass.READ_FUNCTION_NAME) {
|
|
|
- return NAMES.READ;
|
|
|
- } else if (id === this.lexerClass.WRITE_FUNCTION_NAME) {
|
|
|
- return NAMES.WRITE;
|
|
|
- } else {
|
|
|
+ const name = LanguageDefinedFunction.getInternalName(id);
|
|
|
+ console.log('###');
|
|
|
+ console.log(id);
|
|
|
+ console.log(name);
|
|
|
+ console.log('###');
|
|
|
+ if (name === null) {
|
|
|
return id;
|
|
|
+ } else {
|
|
|
+ return name;
|
|
|
}
|
|
|
}
|
|
|
|