Last active
August 29, 2015 13:57
-
-
Save cohalz/9405161 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Vimなどに使えるScala系のdictファイルを生成することができます | |
//先にdefのある行をgrepしてお使いください | |
//例: | |
//grep -h def -r ~/scalaz-scalaz-seven > scalaz.txt | |
//scala scalaToDict.scala scalaz.txt > scalaz.dict | |
import scala.io.Source | |
val regSym = """def\s([^0-9a-zA-Z_]+?)[\s\(\[]+""".r | |
val regAlf = """def\s(.+?)[^0-9a-zA-Z_]""".r | |
if(args.length > 0) { | |
val lines = Source.fromFile(args(0)).getLines().toList | |
val defdictSym = for{ | |
line <- lines | |
if !(line contains "private def") && !(line contains "implicit def") && !(line contains "protected def") | |
reg1 <- regSym.findFirstMatchIn(line) | |
} yield reg1.group(1) | |
val defdictAlf = for{ | |
line <- lines | |
if !(line contains "private def") && !(line contains "implicit def") && !(line contains "protected def") | |
reg2 <- regAlf.findFirstMatchIn(line) | |
} yield reg2.group(1) | |
val defdictsorted = (defdictSym ::: defdictAlf).sorted.distinct | |
defdictsorted.foreach(println) | |
} | |
else Console.err.println("Please enter inputfile") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment