427 def WriteSemanticMaps(self):
428
429 self.CommonHeaderFileScala.write("object ScriptEvalFunc {\n object ScriptOperators extends ChiselEnum {\n val ")
430
431 Counter = 0
432 CheckForDuplicateList = []
433
434 self.CommonHeaderFile.write("#define " + "FUNC_UNDEFINED " + str(Counter) + "\n")
435 self.CommonHeaderFileScala.write("sFunc" + "Undefined")
436 Counter += 1
437
438 for X in self.OperatorsOneOperand:
439
440 if X not in CheckForDuplicateList:
441 self.CommonHeaderFile.write("#define " + "FUNC_" + X.upper() + " " + str(Counter) + "\n")
442 self.CommonHeaderFileScala.write(", sFunc" + X.capitalize())
443
444 CheckForDuplicateList.append(X)
445 Counter += 1
446
447 for X in self.OperatorsTwoOperand:
448
449 if X not in CheckForDuplicateList:
450 self.CommonHeaderFile.write("#define " + "FUNC_" + X.upper() + " " + str(Counter) + "\n")
451 self.CommonHeaderFileScala.write(", sFunc" + X.capitalize())
452 CheckForDuplicateList.append(X)
453 Counter += 1
454
455 for X in self.SemantiRulesList:
456
457 if X not in CheckForDuplicateList:
458 self.CommonHeaderFile.write("#define " + "FUNC_" + X.upper() + " " + str(Counter) + "\n")
459 self.CommonHeaderFileScala.write(", sFunc" + X.capitalize())
460 CheckForDuplicateList.append(X)
461 Counter += 1
462
463 for X in self.keywordList:
464
465 if X not in CheckForDuplicateList:
466 self.CommonHeaderFile.write("#define " + "FUNC_" + X.upper() + " " + str(Counter) + "\n")
467
468
469
470
471 self.CommonHeaderFileScala.write(", sFunc" + X.capitalize() + "")
472
473 CheckForDuplicateList.append(X)
474 Counter += 1
475
476
477 self.CommonHeaderFileScala.write(" = Value\n }\n} ")
478
479
480 self.SourceFile.write("const SYMBOL_MAP SemanticRulesMapList[]= {\n")
481 self.HeaderFile.write("extern const SYMBOL_MAP SemanticRulesMapList[];\n")
482
483 for X in self.OperatorsOneOperand:
484 self.SourceFile.write("{\"@" + X.upper() + "\", "+ "FUNC_" + X.upper() + "},\n")
485
486 for X in self.OperatorsTwoOperand:
487 self.SourceFile.write("{\"@" + X.upper() + "\", "+ "FUNC_" + X.upper() + "},\n")
488
489 for X in self.SemantiRulesList:
490 self.SourceFile.write("{\"@" + X.upper() + "\", "+ "FUNC_" + X.upper() + "},\n")
491
492 for X in self.keywordList:
493 self.SourceFile.write("{\"@" + X.upper() + "\", "+ "FUNC_" + X.upper() + "},\n")
494
495
496
497 self.SourceFile.write("};\n")
498
499 CheckForDuplicateList = []
500 self.CommonHeaderFile.write("\nstatic const char *const FunctionNames[] = {")
501 self.CommonHeaderFile.write("\n\"FUNC_UNDEFINED\""+ ",\n")
502 for X in self.OperatorsOneOperand:
503 if X not in CheckForDuplicateList:
504 self.CommonHeaderFile.write("\"" + "FUNC_" + X.upper() + "\"" + ",\n")
505 CheckForDuplicateList.append(X)
506
507 for X in self.OperatorsTwoOperand:
508 if X not in CheckForDuplicateList:
509 self.CommonHeaderFile.write("\"" + "FUNC_" + X.upper() + "\"" + ",\n")
510 CheckForDuplicateList.append(X)
511
512 for X in self.SemantiRulesList:
513 if X not in CheckForDuplicateList:
514 self.CommonHeaderFile.write("\"" + "FUNC_" + X.upper() + "\"" + ",\n")
515 CheckForDuplicateList.append(X)
516
517 for X in self.keywordList:
518 if X not in CheckForDuplicateList:
519 self.CommonHeaderFile.write("\"" + "FUNC_" + X.upper() + "\"" + ",\n")
520 CheckForDuplicateList.append(X)
521
522 self.CommonHeaderFile.write("};\n")
523
524