static TexPredefinedFormulaParser()
        {
            typeMappings    = new Dictionary <string, Type>();
            argValueParsers = new Dictionary <string, ArgumentValueParser>();
            actionParsers   = new Dictionary <string, ActionParser>();
            formulaParser   = new TexFormulaParser();

            typeMappings.Add("Formula", typeof(TexFormula));
            typeMappings.Add("string", typeof(string));
            typeMappings.Add("double", typeof(double));
            typeMappings.Add("int", typeof(int));
            typeMappings.Add("bool", typeof(bool));
            typeMappings.Add("char", typeof(char));
            typeMappings.Add("Color", typeof(Color));
            typeMappings.Add("Unit", typeof(TexUnit));
            typeMappings.Add("AtomType", typeof(TexAtomType));

            actionParsers.Add("CreateFormula", new CreateTeXFormulaParser());
            actionParsers.Add("MethodInvocation", new MethodInvocationParser());
            actionParsers.Add("Return", new ReturnParser());

            argValueParsers.Add("Formula", new TeXFormulaValueParser());
            argValueParsers.Add("string", new StringValueParser());
            argValueParsers.Add("double", new DoubleValueParser());
            argValueParsers.Add("int", new IntValueParser());
            argValueParsers.Add("bool", new BooleanValueParser());
            argValueParsers.Add("char", new CharValueParser());
            argValueParsers.Add("Color", new ColorConstantValueParser());
            argValueParsers.Add("Unit", new EnumParser(typeof(TexUnit)));
            argValueParsers.Add("AtomType", new EnumParser(typeof(TexAtomType)));
        }
Example #2
0
 public void AddEmbraced(TexFormula formula, string leftSymbol, string rightSymbol)
 {
     this.Add(
         new FencedAtom(
             null,
             formula?.RootAtom,
             TexFormulaParser.GetDelimiterSymbol(leftSymbol, null),
             TexFormulaParser.GetDelimiterSymbol(rightSymbol, null)));
 }
            public override void Parse(SourceSpan source, XElement element)
            {
                var name = element.AttributeValue("name");
                var args = element.Elements("Argument");

                var argTypes  = GetArgumentTypes(args);
                var argValues = GetArgumentValues(this.TempFormulas, args);

                Debug.Assert(argValues.Length == 1 || argValues.Length == 0);
                TexFormula formula = null;

                if (argValues.Length == 1)
                {
                    var parser = new TexFormulaParser();
                    formula = parser.Parse((string)argValues[0]);
                }
                else
                {
                    formula = new TexFormula();
                }

                this.TempFormulas.Add(name, formula);
            }
Example #4
0
 public TexFormulaHelper(TexFormula formula, SourceSpan source)
 {
     this.formulaParser = new TexFormulaParser();
     this.Formula       = formula;
     this.source        = source;
 }
Example #5
0
 public void AddEmbraced(TexFormula formula, char leftChar, char rightChar)
 {
     AddEmbraced(formula, TexFormulaParser.GetDelimeterMapping(leftChar),
                 TexFormulaParser.GetDelimeterMapping(rightChar));
 }