Polish ProfilesParser internals
This commit is contained in:
		
							parent
							
								
									de113f1d11
								
							
						
					
					
						commit
						ea4c64ebc4
					
				| 
						 | 
					@ -71,8 +71,8 @@ final class ProfilesParser {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			switch (token) {
 | 
								switch (token) {
 | 
				
			||||||
				case "(" -> {
 | 
									case "(" -> {
 | 
				
			||||||
					Profiles contents = parseTokens(expression, tokens, Context.BRACKET);
 | 
										Profiles contents = parseTokens(expression, tokens, Context.PARENTHESIS);
 | 
				
			||||||
					if (context == Context.INVERT) {
 | 
										if (context == Context.NEGATE) {
 | 
				
			||||||
						return contents;
 | 
											return contents;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					elements.add(contents);
 | 
										elements.add(contents);
 | 
				
			||||||
| 
						 | 
					@ -85,10 +85,10 @@ final class ProfilesParser {
 | 
				
			||||||
					assertWellFormed(expression, operator == null || operator == Operator.OR);
 | 
										assertWellFormed(expression, operator == null || operator == Operator.OR);
 | 
				
			||||||
					operator = Operator.OR;
 | 
										operator = Operator.OR;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				case "!" -> elements.add(not(parseTokens(expression, tokens, Context.INVERT)));
 | 
									case "!" -> elements.add(not(parseTokens(expression, tokens, Context.NEGATE)));
 | 
				
			||||||
				case ")" -> {
 | 
									case ")" -> {
 | 
				
			||||||
					Profiles merged = merge(expression, elements, operator);
 | 
										Profiles merged = merge(expression, elements, operator);
 | 
				
			||||||
					if (context == Context.BRACKET) {
 | 
										if (context == Context.PARENTHESIS) {
 | 
				
			||||||
						return merged;
 | 
											return merged;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					elements.clear();
 | 
										elements.clear();
 | 
				
			||||||
| 
						 | 
					@ -97,7 +97,7 @@ final class ProfilesParser {
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				default -> {
 | 
									default -> {
 | 
				
			||||||
					Profiles value = equals(token);
 | 
										Profiles value = equals(token);
 | 
				
			||||||
					if (context == Context.INVERT) {
 | 
										if (context == Context.NEGATE) {
 | 
				
			||||||
						return value;
 | 
											return value;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					elements.add(value);
 | 
										elements.add(value);
 | 
				
			||||||
| 
						 | 
					@ -141,10 +141,9 @@ final class ProfilesParser {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private enum Operator {AND, OR}
 | 
						private enum Operator { AND, OR }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private enum Context { NONE, NEGATE, PARENTHESIS }
 | 
				
			||||||
	private enum Context {NONE, INVERT, BRACKET}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private static class ParsedProfiles implements Profiles {
 | 
						private static class ParsedProfiles implements Profiles {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue