All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.uqbar.apo.parser.APOParser.scala Maven / Gradle / Ivy

There is a newer version: 3.6.3
Show newest version
package com.uqbar.apo.parser

import scala.collection.JavaConversions._
import scala.util.parsing.combinator.syntactical.StandardTokenParsers
import org.reflections.Reflections
import javassist.expr.FieldAccess
import javassist.CtPrimitiveType
import com.uqbar.aop.util.ReflectionLibraryUtil

object APOParser {

  def parse(string: String): String = parse(null, string)

  def parse(fieldAccess: Any, string: String): String = {
    var result = string;

    ReflectionLibraryUtil.getSubTypesOf(classOf[Token[_]]).foreach(subtype => {
      val token: Token[Any] = Class.forName(subtype).newInstance().asInstanceOf[Token[Any]]
      if (result.contains(token.getClass().getSimpleName())) {
        result = result.replace(token.getClass().getSimpleName(), token(fieldAccess));
      }
    })
    return result;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy