Browse Source

Finish new language spec.

tags/v1.0^2
Ben Kurtovic 10 years ago
parent
commit
c475de1c0b
3 changed files with 263 additions and 10 deletions
  1. +17
    -2
      bitshift/languages.py
  2. +243
    -4
      bitshift/languages.yml
  3. +3
    -4
      bitshift/parser/__init__.py

+ 17
- 2
bitshift/languages.py View File

@@ -2,5 +2,20 @@ from os import path


import yaml import yaml


with open(path.join(path.dirname(__file__), "languages.yml")) as lang_yaml:
LANGS = [lang for lang in yaml.load(lang_yaml)["languages"]]
__all__ = ["LANGS", "LANGS_ALL"]

def _load_langs():
filename = path.join(path.dirname(__file__), "languages.yml")
with open(filename) as fp:
data = yaml.load(fp)["languages"]
langs = [it.keys()[0] if isinstance(it, dict) else it for it in data]
all_langs = {}
for i, lang in enumerate(data):
if isinstance(lang, dict):
for val in lang.values()[0]:
all_langs[val] = i
else:
all_langs[lang] = i
return langs, all_langs

LANGS, LANGS_ALL = _load_langs()

+ 243
- 4
bitshift/languages.yml View File

@@ -8,9 +8,13 @@ languages:
- Python 3.0 Traceback - Python 3.0 Traceback
- Python console session - Python console session
- Python Traceback - Python Traceback
- NumPy
- PyPy Log
- C - C
- Java - Java
- Ruby
- Ruby:
- Ruby
- Ruby irb session


# Without parsers: # Without parsers:
- ABAP - ABAP
@@ -29,13 +33,18 @@ languages:
- ANTLR With Python Target - ANTLR With Python Target
- ANTLR With Ruby Target - ANTLR With Ruby Target
- Ada - Ada
- Agda
- Agda:
- Agda
- Literate Agda
- Alloy - Alloy
- AmbientTalk - AmbientTalk
- ApacheConf - ApacheConf
- AppleScript - AppleScript
- AspectJ - AspectJ
- aspx-cs
- aspx-vb
- Asymptote - Asymptote
- autohotkey
- AutoIt - AutoIt
- Awk - Awk
- BBCode - BBCode
@@ -53,7 +62,32 @@ languages:
- Bro - Bro
- "C#" - "C#"
- C++ - C++

- ca65
- CBM BASIC V2
- Ceylon
- CFEngine3
- cfstatement
- ChaiScript
- Chapel
- Cheetah
- Cirru
- Clay
- Clojure:
- Clojure
- ClojureScript
- CMake
- COBOL:
- COBOL
- COBOLFree
- CoffeeScript
- Coldfusion CFC
- Coldfusion HTML
- Common Lisp
- Coq
- Croc
- Cryptol:
- Cryptol
- Literate Cryptol
- CSS: - CSS:
- CSS - CSS
- CSS+Django/Jinja - CSS+Django/Jinja
@@ -65,9 +99,68 @@ languages:
- CSS+PHP - CSS+PHP
- CSS+Ruby - CSS+Ruby
- CSS+Smarty - CSS+Smarty
- CUDA
- Cypher
- Cython
- D
- Darcs Patch
- Dart
- Debian Control file
- Debian Sourcelist
- Delphi
- dg
- Diff
- Django/Jinja
- Docker
- DTD
- Duel
- Dylan:
- Dylan
- Dylan session
- DylanLID
- EBNF
- eC
- ECL
- Eiffel
- Elixir:
- Elixir
- Elixir iex session
- Embedded Ragel
- ERB:
- ERB
- RHTML
- Erlang:
- Erlang
- Erlang erl session
- Evoque
- Factor
- Fancy
- Fantom
- Felix
- Fortran
- FoxPro
- FSharp
- GAP
- GAS
- Genshi
- Genshi Text
- Gettext Catalog
- Gherkin
- GLSL
- Gnuplot
- Go
- Golo
- GoodData-CL
- Gosu
- Gosu Template
- Groff
- Groovy
- Haml
- Handlebars
- Haskell: - Haskell:
- Haskell - Haskell
- Literate Haskell - Literate Haskell
- Haxe
- HTML: - HTML:
- HTML - HTML
- HTML+Cheetah - HTML+Cheetah
@@ -81,6 +174,25 @@ languages:
- HTML+PHP - HTML+PHP
- HTML+Smarty - HTML+Smarty
- HTML+Velocity - HTML+Velocity
- Hxml
- Hy
- Hybris
- IDL
- Idris:
- Idris
- Literate Idris
- Igor
- Inform 6:
- Inform 6
- Inform 6 template
- Inform 7
- INI
- Io
- Ioke
- Jade
- JAGS
- Jasmin
- Java Server Page
- JavaScript: - JavaScript:
- JavaScript - JavaScript
- JavaScript+Cheetah - JavaScript+Cheetah
@@ -93,15 +205,80 @@ languages:
- JavaScript+PHP - JavaScript+PHP
- JavaScript+Ruby - JavaScript+Ruby
- JavaScript+Smarty - JavaScript+Smarty
- JSON
- Julia: - Julia:
- Julia - Julia
- Julia console - Julia console
- Kal
- Kconfig
- Koka
- Kotlin
- Lasso
- Lighttpd configuration file
- Limbo
- LiveScript
- LLVM
- Logos
- Logtalk
- LSL
- Lua
- Makefile - Makefile
- Makefile - Makefile
- Base Makefile - Base Makefile
- Mako
- MAQL
- Mask
- Mason
- Mathematica
- Matlab:
- Matlab
- Matlab session
- MiniD
- Modelica
- Modula-2
- Monkey
- MOOCode
- MoonScript
- MQL
- Mscgen
- MuPAD
- MXML
- Myghty
- NASM
- Nemerle
- nesC
- NewLisp
- Newspeak
- Nginx configuration file
- Nimrod
- Nix
- NSIS
- Objective-C - Objective-C
- Objective-C++ - Objective-C++
- Objective-J - Objective-J
- OCaml
- Octave
- Ooc
- Opa
- OpenEdge ABL
- Pan
- Pawn
- Perl:
- Perl
- Perl6
- PHP
- Pig
- Pike
- PostScript
- POVRay
- PowerShell
- Prolog
- Properties
- Protocol Buffer
- Puppet
- QBasic
- QML
- Racket
- Ragel: - Ragel:
- Ragel - Ragel
- Ragel in C Host - Ragel in C Host
@@ -110,9 +287,65 @@ languages:
- Ragel in Java Host - Ragel in Java Host
- Ragel in Objective C Host - Ragel in Objective C Host
- Ragel in Ruby Host - Ragel in Ruby Host
- RConsole
- Rd
- REBOL
- Red
- Redcode
- reg
- reStructuredText
- Rexx
- RobotFramework
- RPMSpec
- RQL
- RSL
- Rust
- S
- Sass: - Sass:
- Sass - Sass
- SCSS - SCSS
- Scala
- Scalate Server Page
- Scaml
- Scheme
- Scilab
- Shell Session
- Slim
- Smali
- Smalltalk
- Smarty
- Snobol
- SourcePawn
- SPARQL
- SQL:
- SQL
- MySQL
- PL/pgSQL
- PostgreSQL console (psql)
- PostgreSQL SQL dialect
- sqlite3con

- SquidConf
- Stan
- Standard ML
- SWIG
- systemverilog
- Tcl
- Tcsh
- Tea
- TeX
- Todotxt
- Treetop
- TypeScript
- UrbiScript
- Vala
- VB.net
- VCTreeStatus
- Velocity
- verilog
- VGL
- vhdl
- VimL
- XML: - XML:
- XML - XML
- XML+Cheetah - XML+Cheetah
@@ -126,4 +359,10 @@ languages:
- XML+Ruby - XML+Ruby
- XML+Smarty - XML+Smarty
- XML+Velocity - XML+Velocity
- YAML
- XQuery
- XSLT
- Xtend
- YAML:
- YAML
- YAML+Jinja
- Zephir

+ 3
- 4
bitshift/parser/__init__.py View File

@@ -7,7 +7,7 @@ import subprocess
from os import path from os import path
from pygments import lexers as pgl, util from pygments import lexers as pgl, util


from ..languages import LANGS
from ..languages import LANGS, LANGS_ALL
from .python import parse_py from .python import parse_py


__all__ = ["parse", "UnsupportedFileError", "start_parse_servers"] __all__ = ["parse", "UnsupportedFileError", "start_parse_servers"]
@@ -41,11 +41,10 @@ def _lang(codelet):
lex = pgl.guess_lexer_for_filename(codelet.filename, codelet.code) lex = pgl.guess_lexer_for_filename(codelet.filename, codelet.code)
else: else:
lex = pgl.guess_lexer(codelet.code) lex = pgl.guess_lexer(codelet.code)
except util.ClassNotFound:
return LANGS_ALL[lex.name]
except (util.ClassNotFound, KeyError):
raise UnsupportedFileError(codelet.filename) raise UnsupportedFileError(codelet.filename)


return LANGS.index(lex.name)

def _recv_data(server_socket): def _recv_data(server_socket):
""" """
Private function to read string response from a server. It reads a certain Private function to read string response from a server. It reads a certain


Loading…
Cancel
Save