public void SymbolExpression() { var parser = new TestParser(); parser.LoadFrom("./FrontEnd/Syntax/Grammar/symbol_expression.z").ForEach(sexpr => { parser.Parse(sexpr); parser.Parse($"({sexpr})"); }); }
// unary_expression -> ( '!' | '-' ) unary_expression (a) // | ( '++' | '--' ) symbol_expression symbol_operator* (b) // | symbol_expression symbol_operator* ( '++' | '--' )? (c) public void UnaryExpression() { var parser = new TestParser(true); /*var unaryExpressions = parser.LoadFrom("./FrontEnd/Syntax/Grammar/unary_expressions.z"); * * // If the unary_expressions.z file exists and has entries, use it. * if (unaryExpressions.Any()) * { * unaryExpressions.ForEach(ue => parser.Parse(ue)); * return; * }*/ // If the file is empty or does not exist at all, generate a set of unary_expressions using the // symbol_expression and symbol_operator files var symbolExpressions = parser.LoadFrom("./FrontEnd/Syntax/Grammar/symbol_expression.z"); var operators = parser.LoadFrom("./FrontEnd/Syntax/Grammar/symbol_operator.z"); // (a) symbolExpressions.ForEach(symbol => { parser.Parse($"!{symbol}"); parser.Parse($"-{symbol}"); parser.Parse($"!({symbol})"); parser.Parse($"-({symbol})"); parser.Parse($"!{symbol}++"); parser.Parse($"!{symbol}--"); parser.Parse($"!++{symbol}"); parser.Parse($"!--{symbol}"); parser.Parse($"!({symbol})++"); parser.Parse($"!({symbol})--"); parser.Parse($"!++({symbol})"); parser.Parse($"!--({symbol})"); parser.Parse($"-{symbol}++"); parser.Parse($"-{symbol}--"); parser.Parse($"-++{symbol}"); parser.Parse($"- --{symbol}"); parser.Parse($"-++({symbol})"); parser.Parse($"- --({symbol})"); operators.ForEach(@operator => { parser.Parse($"!{symbol}{@operator}"); parser.Parse($"!{symbol}{@operator}++"); parser.Parse($"!({symbol}){@operator}"); parser.Parse($"!({symbol}{@operator})"); parser.Parse($"!({symbol}){@operator}++"); parser.Parse($"!({symbol}{@operator})++"); parser.Parse($"-{symbol}{@operator}"); parser.Parse($"-{symbol}{@operator}++"); parser.Parse($"-({symbol}){@operator}"); parser.Parse($"-({symbol}{@operator})"); parser.Parse($"-({symbol}){@operator}++"); parser.Parse($"-({symbol}{@operator})++"); parser.Parse($"!++{symbol}{@operator}"); parser.Parse($"!++({symbol}){@operator}"); parser.Parse($"!++({symbol}{@operator})"); parser.Parse($"-++{symbol}{@operator}"); parser.Parse($"-++({symbol}){@operator}"); parser.Parse($"-++({symbol}{@operator})"); operators.ForEach(operator2 => { parser.Parse($"!{symbol}{@operator}{operator2}"); parser.Parse($"!({symbol}){@operator}{operator2}"); parser.Parse($"!({symbol}{@operator}){operator2}"); parser.Parse($"!({symbol}{@operator}{operator2})"); parser.Parse($"!{symbol}{@operator}{operator2}++"); parser.Parse($"!({symbol}){@operator}{operator2}++"); parser.Parse($"!({symbol}{@operator}){operator2}++"); parser.Parse($"!({symbol}{@operator}{operator2})++"); parser.Parse($"!++{symbol}{@operator}{operator2}"); parser.Parse($"!++({symbol}){@operator}{operator2}"); parser.Parse($"!++({symbol}{@operator}){operator2}"); parser.Parse($"!++({symbol}{@operator}{operator2})"); parser.Parse($"-{symbol}{@operator}{operator2}"); parser.Parse($"-({symbol}){@operator}{operator2}"); parser.Parse($"-({symbol}{@operator}){operator2}"); parser.Parse($"-({symbol}{@operator}{operator2})"); parser.Parse($"-{symbol}{@operator}{operator2}++"); parser.Parse($"-({symbol}){@operator}{operator2}++"); parser.Parse($"-({symbol}{@operator}){operator2}++"); parser.Parse($"-({symbol}{@operator}{operator2})++"); parser.Parse($"-++{symbol}{@operator}{operator2}"); parser.Parse($"-++({symbol}){@operator}{operator2}"); parser.Parse($"-++({symbol}{@operator}){operator2}"); parser.Parse($"-++({symbol}{@operator}{operator2})"); }); }); operators.ForEach(@operator => { parser.Parse($"!{symbol}{@operator}"); parser.Parse($"!({symbol}){@operator}"); parser.Parse($"!({symbol}{@operator})"); parser.Parse($"!{symbol}{@operator}--"); parser.Parse($"!({symbol}){@operator}--"); parser.Parse($"!({symbol}{@operator})--"); parser.Parse($"!--{symbol}{@operator}"); parser.Parse($"!--({symbol}){@operator}"); parser.Parse($"!--({symbol}{@operator})"); parser.Parse($"-{symbol}{@operator}"); parser.Parse($"-({symbol}){@operator}"); parser.Parse($"-({symbol}{@operator})"); parser.Parse($"-{symbol}{@operator}--"); parser.Parse($"-({symbol}){@operator}--"); parser.Parse($"-({symbol}{@operator})--"); parser.Parse($"- --{symbol}{@operator}"); parser.Parse($"- --({symbol}){@operator}"); parser.Parse($"- --({symbol}{@operator})"); operators.ForEach(operator2 => { parser.Parse($"!{symbol}{@operator}{operator2}"); parser.Parse($"!({symbol}){@operator}{operator2}"); parser.Parse($"!({symbol}{@operator}){operator2}"); parser.Parse($"!({symbol}{@operator}{operator2})"); parser.Parse($"!{symbol}{@operator}{operator2}--"); parser.Parse($"!({symbol}){@operator}{operator2}--"); parser.Parse($"!({symbol}{@operator}){operator2}--"); parser.Parse($"!({symbol}{@operator}{operator2})--"); parser.Parse($"!--{symbol}{@operator}{operator2}"); parser.Parse($"!--({symbol}){@operator}{operator2}"); parser.Parse($"!--({symbol}{@operator}){operator2}"); parser.Parse($"!--({symbol}{@operator}{operator2})"); parser.Parse($"-{symbol}{@operator}{operator2}"); parser.Parse($"-({symbol}){@operator}{operator2}"); parser.Parse($"-({symbol}{@operator}){operator2}"); parser.Parse($"-({symbol}{@operator}{operator2})"); parser.Parse($"-{symbol}{@operator}{operator2}--"); parser.Parse($"-({symbol}){@operator}{operator2}--"); parser.Parse($"-({symbol}{@operator}){operator2}--"); parser.Parse($"-({symbol}{@operator}{operator2})--"); parser.Parse($"- --{symbol}{@operator}{operator2}"); parser.Parse($"- --({symbol}){@operator}{operator2}"); parser.Parse($"- --({symbol}{@operator}){operator2}"); parser.Parse($"- --({symbol}{@operator}{operator2})"); }); }); }); // (b); symbolExpressions.ForEach(symbol => { // '++' symbol_expression parser.Parse($"++{symbol}"); parser.Parse($"++({symbol})"); // '--' symbol_expression parser.Parse($"--{symbol}"); parser.Parse($"--({symbol})"); // '++' symbol_expression symbol_operator operators.ForEach(@operator => { parser.Parse($"++{symbol}{@operator}"); parser.Parse($"++({symbol}){@operator}"); parser.Parse($"++({symbol}{@operator})"); // '++' symbol_expression symbol_operator symbol_operator operators.ForEach(operator2 => { parser.Parse($"++{symbol}{@operator}{operator2}"); parser.Parse($"++({symbol}){@operator}{operator2}"); parser.Parse($"++({symbol}{@operator}){operator2}"); parser.Parse($"++({symbol}{@operator}{operator2})"); }); }); // '--' symbol_expression symbol_operator operators.ForEach(@operator => { parser.Parse($"--{symbol}{@operator}"); parser.Parse($"--({symbol}){@operator}"); parser.Parse($"--({symbol}{@operator})"); // '++' symbol_expression symbol_operator symbol_operator operators.ForEach(operator2 => { parser.Parse($"--{symbol}{@operator}{operator2}"); parser.Parse($"--({symbol}){@operator}{operator2}"); parser.Parse($"--({symbol}{@operator}){operator2}"); parser.Parse($"--({symbol}{@operator}{operator2})"); }); }); }); // (c); symbolExpressions.ForEach(symbol => { parser.Parse($"{symbol}++"); parser.Parse($"({symbol})++"); parser.Parse($"{symbol}--"); parser.Parse($"({symbol})--"); operators.ForEach(accessor => { parser.Parse($"{symbol}{accessor}++"); parser.Parse($"({symbol}){accessor}++"); parser.Parse($"({symbol}{accessor})++"); operators.ForEach(accessor2 => { parser.Parse($"{symbol}{accessor}{accessor2}++"); parser.Parse($"({symbol}){accessor}{accessor2}++"); parser.Parse($"({symbol}{accessor}){accessor2}++"); parser.Parse($"({symbol}{accessor}{accessor2})++"); }); }); operators.ForEach(accessor => { parser.Parse($"{symbol}{accessor}--"); parser.Parse($"({symbol}){accessor}--"); parser.Parse($"({symbol}{accessor})--"); operators.ForEach(accessor2 => { parser.Parse($"{symbol}{accessor}{accessor2}--"); parser.Parse($"({symbol}){accessor}{accessor2}--"); parser.Parse($"({symbol}{accessor}){accessor2}--"); parser.Parse($"({symbol}{accessor}{accessor2})--"); }); }); }); // Save the file parser.SaveTo("./FrontEnd/Syntax/Grammar/unary_expressions.z"); }
public void Primary() { var parser = new TestParser(); parser.LoadFrom("./FrontEnd/Syntax/Grammar/primary.z").ForEach(l => parser.Parse(l)); }
public void TupleExpression() { var parser = new TestParser(); parser.LoadFrom("./FrontEnd/Syntax/Grammar/tuple_expression.z").ForEach(l => parser.Parse(l)); }
public void ArrayInitializer() { var parser = new TestParser(); parser.LoadFrom("./FrontEnd/Syntax/Grammar/array_expression.z").ForEach(l => parser.Parse(l)); }