当前位置: 首页>>代码示例>>Scala>>正文


Scala Position类代码示例

本文整理汇总了Scala中scala.util.parsing.input.Position的典型用法代码示例。如果您正苦于以下问题:Scala Position类的具体用法?Scala Position怎么用?Scala Position使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Position类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: Test

//设置package包名称以及导入依赖的类
package de.dfki.cps.specific.sysml

import java.io.File
import java.util

import de.dfki.cps.specific.SysML
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import scala.collection.mutable
import scala.util.parsing.input.Position


object Test extends App {
  implicit lazy val rs = new ResourceSetImpl
  Synthesis.prepareLibrary(rs)

  args.map(new File(_)) match {
    case Array(file) if file.exists() && file.getName == "index.sysml" =>
      println("loading project")
      val projectURI = URI.createFileURI(file.getPath)

      val resource = rs.createResource(projectURI.appendFileExtension("ecore"))

      val positions = mutable.Map.empty[EObject,(String,Position)]

      def load = (uri: URI) => {
        println(s"loading $uri")
        val resource = rs.createResource(uri.appendFileExtension("ecore"))
        val positions = SysML.load(new File(uri.toFileString),resource)
        resource.save(new util.HashMap)
        resource
      }

      SysML.loadProject(projectURI, resource, load)

      println("saving")

      resource.save(new util.HashMap)

      println("done.")
    case Array(file) if file.exists() =>
      val uri = URI.createFileURI(file.getPath)
      println(s"loading $file")
      val resource = rs.createResource(uri.appendFileExtension("ecore"))
      val positions = SysML.load(new File(uri.toFileString),resource)
      resource.save(new util.HashMap)
      println("done.")
    case Array(file) =>
      println(s"file not found: $file")
    case other =>
      println("usage: specific-sysml <sourcefile>")
  }
} 
开发者ID:DFKI-CPS,项目名称:specific-sysml,代码行数:55,代码来源:Test.scala

示例2: Print

//设置package包名称以及导入依赖的类
package mur

import scala.collection.mutable
import scala.util.parsing.input.{Position, Positional}

sealed trait Stmt extends Positional
case class Print(str: String) extends Stmt
case class Out(expr: Expr) extends Stmt
case class VarDef(identifier: String, expr: Expr) extends Stmt

case class Program(stmts: Seq[Stmt])

object Program {
  def positions(prog: Program, set: mutable.Set[Position]): Unit = {
    prog.stmts foreach {stmt =>
      set.add(stmt.pos)
      stmt match {
        case _: Print => ()
        case Out(expr) =>
          Expr.positions(expr, set)
        case VarDef(_, expr) =>
          Expr.positions(expr, set)
      }
    }
  }
} 
开发者ID:MaxGekk,项目名称:mur,代码行数:27,代码来源:IR.scala

示例3: run

//设置package包名称以及导入依赖的类
package mur

import com.typesafe.config.ConfigFactory

import scala.collection.mutable
import scala.util.parsing.input.{NoPosition, Position}


  def run(prog: Program): Result = {
    var ctx = Context()
    var result: Result = Right(Seq())

    for (stmt <- Optimizer(prog).stmts if result.isRight) {
      stmt match {
        // Print a string like : print "Hello, World!"
        case Print(str) =>
          result = Right(result.right.get :+ str)
        // Evaluate the expression, convert result to a string and print it
        case Out(expr) =>
          Expr.calc(expr, ctx) match {
            case Right(value) =>
              result = Right(result.right.get :+ value.toString)
            case Left(error) =>
              result = Left(error)
          }
        // Define new variable (override old one), get its value eagerly
        // and keep it in the context
        case VarDef(id, expr) =>
          Expr.calc(expr, ctx) match {
            case Right(value) =>
              ctx = ctx.copy(ids = ctx.ids.updated(id, value))
            case Left(error) =>
              result = Left(error)
          }
      }
    }

    result
  }
} 
开发者ID:MaxGekk,项目名称:mur,代码行数:41,代码来源:Interpreter.scala

示例4: LiteralValue

//设置package包名称以及导入依赖的类
package xyz.hyperreal.rdb

import scala.util.parsing.input.Position

import xyz.hyperreal.lia.FunctionMap


trait ValueResult {
	val pos: Position
	val table: String
	val heading: String
	val typ: Type
}

case class LiteralValue( pos: Position, table: String, heading: String, typ: Type, value: AnyRef ) extends ValueResult
case class VariableValue( pos: Position, table: String, heading: String, typ: Type, value: AnyRef ) extends ValueResult
case class FieldValue( pos: Position, table: String, heading: String, typ: Type, index: Int, depth: Int ) extends ValueResult
case class MarkedValue( pos: Position, table: String, heading: String, typ: Type, m: Mark ) extends ValueResult
case class BinaryValue( pos: Position, table: String, heading: String, typ: Type, left: ValueResult, operation: String, func: FunctionMap,
												right: ValueResult ) extends ValueResult
case class AggregateFunctionValue( pos: Position, table: String, heading: String, typ: Type, af: AggregateFunction, args: List[ValueResult] ) extends ValueResult {
	var func: AggregateFunctionInstance = _
	}
case class ScalarFunctionValue( pos: Position, table: String, heading: String, typ: Type, func: ScalarFunction, args: List[ValueResult] ) extends ValueResult
case class UnaryValue( pos: Position, table: String, heading: String, typ: Type, v: ValueResult, operation: String, func: FunctionMap ) extends ValueResult
case class LogicalValue( pos: Position, table: String, heading: String, typ: Type, logical: LogicalResult ) extends ValueResult
case class AliasValue( pos: Position, table: String, heading: String, typ: Type, apos: Position, v: ValueResult ) extends ValueResult 
开发者ID:edadma,项目名称:rdb,代码行数:28,代码来源:ValueResult.scala

示例5: AssignRelationStatement

//设置package包名称以及导入依赖的类
package xyz.hyperreal.rdb

import scala.util.parsing.input.{Positional, Position}

import xyz.hyperreal.lia.FunctionMap


trait AST

trait StatementAST extends AST
case class AssignRelationStatement( variable: Ident, relation: RelationExpression ) extends StatementAST
case class CreateBaseRelationStatement( base: Ident, columns: List[ColumnDef] ) extends StatementAST
case class DropTableStatement( base: Ident ) extends StatementAST
case class InsertRelationStatement( base: Ident, relation: RelationExpression ) extends StatementAST
case class InsertTupleseqStatement( base: Ident, tupleseq: TupleseqExpression ) extends StatementAST
case class InsertTupleStatement( base: Ident, tupl: TupleExpression ) extends StatementAST
case class DeleteStatement( base: Ident, condition: LogicalExpression ) extends StatementAST
case class UpdateStatement( base: Ident, condition: LogicalExpression, updates: List[(Ident, ValueExpression)] ) extends StatementAST

trait ValueExpression extends AST with Positional
case class FloatLit( n: String ) extends ValueExpression
case class IntegerLit( n: String ) extends ValueExpression
case class StringLit( s: String ) extends ValueExpression
case class MarkLit( m: Mark ) extends ValueExpression
case class ValueVariableExpression( name: Ident ) extends ValueExpression
case class ValueColumnExpression( table: Ident, column: Ident ) extends ValueExpression
case class TupleExpression( t: List[ValueExpression] ) extends ValueExpression
case class BinaryValueExpression( left: ValueExpression, oppos: Position, operation: String, func: FunctionMap, right: ValueExpression ) extends ValueExpression
case class ApplicativeValueExpression( func: ValueExpression, args: List[ValueExpression] ) extends ValueExpression
case class UnaryValueExpression( oppos: Position, operation: String, func: FunctionMap, expr: ValueExpression ) extends ValueExpression
case class LogicalValueExpression( logical: LogicalExpression ) extends ValueExpression
case class AliasValueExpression( expr: ValueExpression, alias: Ident ) extends ValueExpression

trait TupleCollectionExpression extends StatementAST
trait RelationExpression extends TupleCollectionExpression with Positional
case class RelationVariableExpression( name: Ident ) extends RelationExpression
case class ListRelationExpression( columns: List[ColumnSpec], data: List[TupleExpression] ) extends RelationExpression
case class ProjectionRelationExpression( relation: RelationExpression, columns: List[ValueExpression] ) extends RelationExpression
case class SelectionRelationExpression( relation: RelationExpression, condition: LogicalExpression ) extends RelationExpression
case class InnerJoinRelationExpression( left: RelationExpression, condition: LogicalExpression, right: RelationExpression ) extends RelationExpression
case class GroupingRelationExpression( relation: RelationExpression, discriminator: List[ValueExpression], filter: Option[LogicalExpression], cpos: Position, columns: List[ValueExpression] ) extends RelationExpression

trait TupleseqExpression extends TupleCollectionExpression  with Positional
case class TupleseqLit( data: List[TupleExpression] ) extends TupleseqExpression
case class SortedTupleseqExpression( relation: RelationExpression, names: List[Ident], ascending: Boolean ) extends TupleseqExpression

trait LogicalExpression extends Positional
case class LiteralLogicalExpression( l: Logical ) extends LogicalExpression
case class ComparisonLogicalExpression( left: ValueExpression, comp: List[(String, FunctionMap, ValueExpression)] ) extends LogicalExpression
case class AndLogicalExpression( left: LogicalExpression, right: LogicalExpression ) extends LogicalExpression
case class OrLogicalExpression( left: LogicalExpression, right: LogicalExpression ) extends LogicalExpression
case class ExistsLogicalExpression( tuples: TupleCollectionExpression ) extends LogicalExpression

case class Ident( pos: Position, name: String )

case class ColumnSpec( name: Ident, typepos: Position, typ: Option[String] )
case class ColumnDef( name: Ident, typepos: Position, typ: Type, pkpos: Position, fkr: Ident, fkc: Ident, unmarkable: Boolean, auto: Boolean ) 
开发者ID:edadma,项目名称:rdb,代码行数:58,代码来源:AST.scala


注:本文中的scala.util.parsing.input.Position类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。