Showing posts with label Scala. Show all posts
Showing posts with label Scala. Show all posts

Wednesday, June 2, 2010

Scala tokenizer

Today I found out that scala compiler allows to print stats about tokens used in code with command line tokenizer. To use it from eclipse:
  1. create debug configuration and point Main class to scala.tools.cmd.program.Tokens
  2. on program arguments set HelloWorld.scala --verbose –freq
  3. add standard scala classpath for scala debuging you can find it: here
On the output you will see tokens stats like below:
Tokenizing: HelloWorld.scala
2 '}'
2 '{'
1 '['
1 '='
1 args
1 main
1 ':'
1 'def'
1 'object'
1 '('
1 ']'
1 Hello
1 String
1 Array
1 ')'
Rather simple but sometimes useful.

Tuesday, May 25, 2010

Mini how-to for building Scala from SVN

Steps to setup development environment for Scala compiler with Eclipse Scala plug-in:
  1. Install JDK 1.6.0 or above (e.g. Sun JDK 6.0 version 1.6.0_19):
    • JDK is available on http://java.sun.com/.
    • Remember to set the JAVA_HOME environment variable after installation.
    • (Optional) Add JAVA_HOME/bin to PATH for executing Java commands.
  2. If you want to use Eclipse then install Eclipse 3.5 or above (e.g. Eclipse 3.5.2): 
  3. Install Scala plug-in for Eclipse
  4. Extract Scala source, either:
    • If using Eclipse:
      • Decide where your workspace is (will be reference later), switch to the SVN perspective. If you are not familiar with Eclipse, in menu Help -> Welcome may help you a lot.
      • Browse SVN to know SVN information.
      • Create a new repository, extract scala source
    • If not using Eclipse then from command line: svn co http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk scala
  5. Build Scala compiler source
    • If you want to build from the command line with ANT check link: http://www.scala-lang.org/node/217
    • For Eclipse:
      • Open in any text editor file .classpath from root folder and add after tag <classpath>
      <classpathentry kind="con" path="ch.epfl.lamp.sdt.launching.SCALA_CONTAINER"/>
      • Close File
      • Import src catalog to eclipse workspace
      • Right click on build.xml and select Run As -> Ant Build optionally you can just use shortcut Alt+Shift+X,Q
  6. Debug Compiler
    • Add new deconfiguration by click on and selecting from menu Debug Configuration…
    • Add new item under Scala Application
    • create HelloWorld.scala file under root folder and paste sample Scala code
    • under Main tab set Main class to: scala.tools.nsc.Main
    • under Arguments tab (Remember to replace {PathToSrc} with path to Scala src) set
      • Program arguments: HelloWorld.scala -target:jvm-1.5 -d bin
      • VM arguments: -Xbootclasspath/a:{PathToSrc}\build\pack\lib\scala-compiler.jar;{PathToSrc}\build\pack\lib\scala-library.jar;{PathToSrc}\build\pack\lib\fjbg.jar;{PathToSrc}\build\pack\lib\msil.jar;{PathToSrc}\lib\original_msil.jar
  7. Done!
In case of any problems please let me know.

Thursday, May 6, 2010

Warm up: mini-project with Scala

During next few days I am going to start implementing enhancement Optimize simple for loops.  During this warm up project I would like to gain more practice with Scala.Net which can be later useful with main GSoC project.

This project was suggested to me by Miguel because it is almost self-contained and also important to the community.

I will keep you informed about progress :).

Tuesday, May 4, 2010

Good News: GSoC 2010 with Scala.Net

My application "Adding LINQ-awareness to Scala.Net" to Google Summer of Code 2010 was accepted thanks for countless help to Miguel Garcia.

Project aim is to add support for LINQ to Scala.Net compiler. To provide this feature to Scala.Net requires modification in parser and adding transformation to verify SQO expressions for data sources which type enables to indicate support for this capability. Once the proposed extension has been implemented, making use of it requires no additional expertise beyond familiarity with the same .NET tools for LINQ.The idea was proposed by Miguel Garcia on Scala Compiler Corner.

Few words about the program: "Google Summer of Code (GSoC) is a global program that offers student developers stipends to write code for various open source software projects."
Linkt to site: http://socghop.appspot.com/

During next few months on this blog I will be posting progress of this project so stay tuned.