new parser handles enum values (#3492)
* simplify * poke to force generate * enums * jar * jar * poke * prepends formatted * prepends * eol * eol * allow no endl at eof * Revert "eol" This reverts commit 022029faef338281b1a3551f82e46c4b6a7578a5. * Revert "eol" This reverts commit 6274502db740569235210916fde4ec84863d7fb3.
This commit is contained in:
parent
17a6f81365
commit
4f9df2a110
|
@ -3,8 +3,8 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
//Jokeri says it's better with full pinout just in case
|
||||
//#define ts_show_full_pinout false
|
||||
! Jokeri says it's better with full pinout just in case
|
||||
! #define ts_show_full_pinout false
|
||||
|
||||
#define ts_show_lcd false
|
||||
#define ts_show_joystick false
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
//Jokeri says it's better with full pinout just in case
|
||||
//#define ts_show_full_pinout false
|
||||
! Jokeri says it's better with full pinout just in case
|
||||
! #define ts_show_full_pinout false
|
||||
|
||||
#define ts_show_lcd false
|
||||
#define ts_show_joystick false
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
//Jokeri says it's better with full pinout just in case
|
||||
//#define ts_show_full_pinout false
|
||||
! Jokeri says it's better with full pinout just in case
|
||||
! #define ts_show_full_pinout false
|
||||
|
||||
#define ts_show_lcd false
|
||||
#define ts_show_joystick false
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
//Jokeri says it's better with full pinout just in case
|
||||
//#define ts_show_full_pinout false
|
||||
! Jokeri says it's better with full pinout just in case
|
||||
! #define ts_show_full_pinout false
|
||||
|
||||
#define ts_show_lcd false
|
||||
#define ts_show_joystick false
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
//Jokeri says it's better with full pinout just in case
|
||||
//#define ts_show_full_pinout false
|
||||
! Jokeri says it's better with full pinout just in case
|
||||
! #define ts_show_full_pinout false
|
||||
|
||||
#define ts_show_lcd false
|
||||
#define ts_show_joystick false
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
//Jokeri says it's better with full pinout just in case
|
||||
//#define ts_show_full_pinout false
|
||||
! Jokeri says it's better with full pinout just in case
|
||||
! #define ts_show_full_pinout false
|
||||
|
||||
#define ts_show_lcd false
|
||||
#define ts_show_joystick false
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
//Jokeri says it's better with full pinout just in case
|
||||
//#define ts_show_full_pinout false
|
||||
! Jokeri says it's better with full pinout just in case
|
||||
! #define ts_show_full_pinout false
|
||||
|
||||
#define ts_show_lcd false
|
||||
#define ts_show_joystick false
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
//Jokeri says it's better with full pinout just in case
|
||||
//#define ts_show_full_pinout false
|
||||
! Jokeri says it's better with full pinout just in case
|
||||
! #define ts_show_full_pinout false
|
||||
|
||||
#define ts_show_lcd false
|
||||
#define ts_show_joystick false
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
//Jokeri says it's better with full pinout just in case
|
||||
//#define ts_show_full_pinout false
|
||||
! Jokeri says it's better with full pinout just in case
|
||||
! #define ts_show_full_pinout false
|
||||
|
||||
#define ts_show_lcd false
|
||||
#define ts_show_joystick false
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#define ts_show_hip9011 false
|
||||
#define ts_show_cj125 false
|
||||
|
||||
//Jokeri says it's better with full pinout just in case
|
||||
//#define ts_show_full_pinout false
|
||||
! Jokeri says it's better with full pinout just in case
|
||||
! #define ts_show_full_pinout false
|
||||
|
||||
#define ts_show_lcd false
|
||||
#define ts_show_joystick false
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//TODO: understand this.
|
||||
!TODO: understand this.
|
||||
|
||||
#define ts_show_hip9011 true
|
||||
#define ts_show_cj125 false
|
||||
|
|
|
@ -1987,5 +1987,3 @@ end_struct
|
|||
! we need to improve this further - at the moment we need too many boards to prepend 'false'
|
||||
#define show_test_presets true
|
||||
#define show_Frankenso_presets true
|
||||
|
||||
! poke
|
||||
|
|
Binary file not shown.
|
@ -138,7 +138,7 @@ rootStatement
|
|||
;
|
||||
|
||||
rootStatements
|
||||
: (rootStatement ENDL+)*
|
||||
: (rootStatement ENDL+)* rootStatement
|
||||
;
|
||||
|
||||
// Statements are allowed to appear inside a struct
|
||||
|
|
|
@ -227,14 +227,14 @@ public class ConfigDefinition {
|
|||
state.read(new FileReader(ef));
|
||||
}
|
||||
|
||||
SystemOut.println(state.enumsReader.getEnums() + " total enumsReader");
|
||||
SystemOut.println(state.enumsReader.getEnums().size() + " total enumsReader");
|
||||
}
|
||||
|
||||
ParseState parseState = new ParseState(state.enumsReader);
|
||||
// Add the variable for the config signature
|
||||
long crc32 = signatureHash(state, parseState, tsPath, inputAllFiles);
|
||||
|
||||
handleFiringOrder(firingEnumFileName, state.variableRegistry);
|
||||
handleFiringOrder(firingEnumFileName, state.variableRegistry, parseState);
|
||||
|
||||
MESSAGE = ToolUtil.getGeneratedAutomaticallyTag() + definitionInputFile + " " + new Date();
|
||||
|
||||
|
@ -252,18 +252,14 @@ public class ConfigDefinition {
|
|||
// First process yaml files
|
||||
//processYamls(parseState, yamlFiles);
|
||||
|
||||
// Process firing order enum
|
||||
handleFiringOrder(firingEnumFileName, parseState);
|
||||
|
||||
// Load prepend files
|
||||
{
|
||||
// Ignore duplicates of definitions made during prepend phase
|
||||
parseState.setDefinitionPolicy(Definition.OverwritePolicy.IgnoreNew);
|
||||
|
||||
//for (String prependFile : prependFiles) {
|
||||
// TODO: fix signature define file parsing
|
||||
//parseFile(parseState, prependFile);
|
||||
//}
|
||||
for (String prependFile : prependFiles) {
|
||||
parseFile(parseState.getListener(), prependFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Now load the main config file
|
||||
|
@ -331,17 +327,12 @@ public class ConfigDefinition {
|
|||
CachingStrategy.saveCachedInputFiles(inputAllFiles, cachePath, cacheZipFile);
|
||||
}
|
||||
|
||||
private static void handleFiringOrder(String firingEnumFileName, VariableRegistry variableRegistry) throws IOException {
|
||||
private static void handleFiringOrder(String firingEnumFileName, VariableRegistry variableRegistry, ParseState parseState) throws IOException {
|
||||
if (firingEnumFileName != null) {
|
||||
SystemOut.println("Reading firing from " + firingEnumFileName);
|
||||
variableRegistry.register("FIRINGORDER", FiringOrderTSLogic.invoke(firingEnumFileName));
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleFiringOrder(String firingEnumFileName, ParseState parser) throws IOException {
|
||||
if (firingEnumFileName != null) {
|
||||
SystemOut.println("Reading firing from " + firingEnumFileName);
|
||||
parser.addDefinition("FIRINGORDER", FiringOrderTSLogic.invoke(firingEnumFileName), Definition.OverwritePolicy.NotAllowed);
|
||||
String result = FiringOrderTSLogic.invoke(firingEnumFileName);
|
||||
variableRegistry.register("FIRINGORDER", result);
|
||||
parseState.addDefinition("FIRINGORDER", result, Definition.OverwritePolicy.NotAllowed);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,27 @@ public class ParseState {
|
|||
|
||||
public ParseState(EnumsReader enumsReader) {
|
||||
this.enumsReader = enumsReader;
|
||||
|
||||
for (Map.Entry<String, EnumsReader.EnumState> enumType : this.enumsReader.getEnums().entrySet()) {
|
||||
String name = enumType.getKey();
|
||||
|
||||
for (Value enumValue : enumType.getValue().values()) {
|
||||
try {
|
||||
int value = enumValue.getIntValue();
|
||||
|
||||
this.handleIntDefinition(name + "_" + enumValue.getName(), value);
|
||||
} catch (Exception exc) {
|
||||
// ignore parse failures
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleIntDefinition(String name, int value) {
|
||||
addDefinition(name, value);
|
||||
|
||||
// Also add ints as 16b hex
|
||||
addDefinition(name + "_16_hex", String.format("\\\\x%02x\\\\x%02x", (value >> 8) & 0xFF, value & 0xFF));
|
||||
}
|
||||
|
||||
private static boolean isNumeric(String str) {
|
||||
|
@ -110,7 +131,7 @@ public class ParseState {
|
|||
public ParseTreeListener getListener() {
|
||||
return new RusefiConfigGrammarBaseListener() {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void exitContent(RusefiConfigGrammarParser.ContentContext ctx) {
|
||||
if (!scopes.empty())
|
||||
throw new IllegalStateException();
|
||||
|
@ -126,13 +147,6 @@ public class ParseState {
|
|||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
private void handleIntDefinition(String name, int value) {
|
||||
addDefinition(name, value);
|
||||
|
||||
// Also add ints as 16b hex
|
||||
addDefinition(name + "_16_hex", String.format("\\\\x%02x\\\\x%02x", (value >> 8) & 0xFF, value & 0xFF));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitDefinition(RusefiConfigGrammarParser.DefinitionContext ctx) {
|
||||
String name = ctx.identifier().getText();
|
||||
|
|
Loading…
Reference in New Issue