Projects tagged ‘language’ and ‘parser’


[13 total ]

26USERS
   

ANother Tool for Language Recognition (ANTLR) is the name of a parser generator that uses LL(k) parsing. ANTLR is the successor to the Purdue Compiler Construction Tool Set (PCCTS), first developed in 1989, and is under active development. Its maintainer is professor Terence Parr of the University of San Francisco.

15USERS
   

Java Compiler Compiler is the most popular parser generator for use with Java applications. A parser generator is a tool that reads a grammar specification and converts it to a Java program that can recognize matches to the grammar. In addition to ... [More] the parser generator itself, JavaCC provides other standard capabilities related to parser generation such as tree building (via a tool called JJTree included with JavaCC), actions, debugging, etc. [Less]

12USERS
   

Spirit is an object-oriented, recursive descent parser generator framework implemented using template meta-programming techniques. Expression templates allow Spirit to approximate the syntax of Extended Backus Normal Form (EBNF) completely in C++. ... [More] The Spirit framework enables a target grammar to be written exclusively in C++. EBNF grammar specifications can mix freely with other C++ code and, thanks to the generative power of C++ templates, are immediately executable. [Less]

6USERS
   

Happy is a parser generator system for Haskell, similar to the tool `yacc' for C. Like `yacc', it takes a file containing an annotated BNF specification of a grammar and produces a Haskell module containing a parser for the grammar. Happy is ... [More] flexible: you can have several Happy parsers in the same program, and several entry points to a single grammar. Happy can work in conjunction with a lexical analyser supplied by the user (either hand-written or generated by another program), or it can parse a stream of characters directly (but this isn't practical in most cases). [Less]

4USERS
 

NLTK — the Natural Language Toolkit — is a suite of open source Python modules, data and documentation for research and development in natural language processing. NLTK contains Code supporting dozens of NLP tasks, along with 30 popular Corpora ... [More] and extensive Documentation including a 360-page online Book. Distributions for Windows, Mac OSX and Linux are available. [Less]

2USERS

Stratego/XT is a language and toolset for program transformation. The Stratego language provides rewrite rules for expressing basic transformations, programmable rewriting strategies for controlling the application of rules, concrete syntax for ... [More] expressing the patterns of rules in the syntax of the object language, and dynamic rewrite rules for expressing context-sensitive transformations, thus supporting the development of transformation components at a high level of abstraction. The XT toolset offers a collection of flexible, reusable transformation components, as well as declarative languages for deriving new components. Complete program transformation systems are composed from these components. [Less]

2USERS
   

SableCC is an object-oriented framework that generates compilers (and interpreters) in the Java programming language.

1USERS
 

Project Lestes is an ongoing effort to make a C++ compiler with comprehensive C++ source code using the most advanced algorithms seen. Other goals include: easilly retargettable compiler, compiler that can be successfully used in teaching compiler construction, compiler that can compile multitude of languages.

1USERS

L is a general-purpose, compiled, extensible programming language. Extensions appear at three different levels: the syntax is completely replacable; Lisp-like macros allows for creation of new construct in the language; new global definitions enable ... [More] to change the paradigm of the language. The language is organised in layers : at the bottom there is a low-level programming language, similar to a C that could enforce strong typing; libraries provide higher level capabilities to the language. The L project provides an interactive compiler for the L programming language and its associated tools: lexer and parser generators, translation from L code to C... [Less]

1USERS

Java based generic scripting engine with dynamic language features. Syntax is also based on the Java language and works transparent with Java VM in that it locates classes on the fly and can also compile .java files in runtime. Recently added prototype functionality (as known from ECMA based scriptlanguages such as Javascript/Actionscript).

1USERS

Haskell-Source with Extensions (HSE, haskell-src-exts) is an extension of the standard haskell-src package, and handles most common syntactic extensions to Haskell.

0USERS

PiHiPi is a simple object-oriented scripting language based on and compatible with PHP http://www.php.net. PiHiPi compiler is able to translate most of php code and also adds some new features to the language. The goal of PiHiPi project is to create ... [More] simpler and more consistent php parser. usagePiHiPi compiler is a standalone command line utility that translates PiHiPi into valid php5 code. The resulting code can be executed or deployed directly, no additional libraries or extensions are required. phicc -o source.ph ... source.phtranslates given PiHiPi (.ph) files into one single php script. If -o option is omitted, phicc prints generated code to standard output, so that you can pipe it with php: phicc source.ph | phpThere's also a shell script, called phi, that does essentially the same: phi source.phcompiles and then executes source.ph installationwindows binariesDownload and unzip windows package. Put phicc.exe somewhere in your path, and phrtl.php in your php include_path. Run tests to make sure everything is ok: php test.phpAfter running tests, it's safe to remove installation directory, phicc.exe and phrtl.php are only two files you need to use PiHiPi. building from sourceYou will need lemon http://www.hwaci.com/sw/lemon and re2c http://re2c.org svn checkout http://pihipi.googlecode.com/svn/trunk/ pihipi cd pihipi make && make testFor Windows MinGW is preferred, .sln file for Microsoft toolchain is included, but not 'officially supported'. ;) language extensionsWith some exceptions, PiHiPi understands any valid php syntax. The following describes features of PiHiPi not found in standard php. For more details and examples look at the files in test and examples directories. layoutCode is enclosed in . Like ?>, closing comment symbol */ can be omitted (assumed at the end of file). is not the same as echo, it's translated into the call to the function web::_print(), which defaults to htmlspecialchars(), but can be redefined: map(str::upper)->join(' '); } ?> (outputs: HI THERE)primitivesString interpolation is performed for arbitrary complex references starting with $ and for arbitrary expressions enclosed in {}: echo "hello $foo->bar->baz[10+20]"; echo "hello {10 + someFunc() + $blah}";There are also two new string delimiters: """ and ''' (triple-double and triple-single quotes). echo """ double "quotes" are ok """; echo ''' single 'quotes' are ok ''';Regular expressions are first class primitives. Regexp literals are enclosed in backticks: $regexp = `[a-z_][a-z0-9_]+`si;arraysAdded shortcut syntax for array literals: $ary = [10, 20, 'foo' => 'bar'];Arrays are objects: echo [1, 2, 3]->join('|'); // 1|2|3operatorsAdded ruby-alike match =~, not match !~ and compare <=> operators. echo 'ABC' =~ `[A-Z]+`; // true echo 'ABC' !~ `[0-9]+`; // true echo 10 <=> 20; // -1Index operator [] can accept two arguments. This form is only allowed on the right and returns substring/subarray: echo '012345'[2, 4]; // '234' echo '012345'[2, -1]; // '2345'Perl semantics for boolean || and &&: echo 5 && 25; // 25 echo 0 || 25; // 25isset and unset are true operators and can be used without parentheses if(isset $a) echo $a; unset $b; echo isset $b;Added new is and in operators. in tests if the value is in array or is a substring of the argument: if(10 in [1, 5, 10, 20]) echo "yes!"; if('bar' in 'foobarbaz') echo "yes!";is acts like a wrapper around php is_a... family of functions: if($var is number) echo "number"; if($var is string) echo "string"; class Foo {} if($var is Foo) echo "var is an object of class Foo";assignmentsAdded support for multiple assignment: $a,$b = 10,20; // a=10,b=20 $a,,$c = 10,20,30; // a=10,c=30 $a,$b,$c = 10,20; // a=10,b=20,c=20expressionsAs a general rule, expression is allowed everywhere a variable can be used, e.g.: echo func()[10]; echo $(get_var_name()); echo $obj->('pro' . 'perty'); echo (new Foo)->bar; echo ('func' . 'name')($arg); $a = new (get_class_name())($args);statementsthrow can throw any object or string: if(!open_foo_bar()) throw 'panic!';catch argument can be arbitrary lvalue, even complex: try { ... } catch($myObj->myErr) { ... }Includes are statements and resolved at compile time i.e. include(expression) is not allowed. Resulting script is monolithic. echo and print are statements, not functions. Also added puts: puts 'Hello';functionsCurly brackets can be omitted if function body is a single statement. Added support for named call arguments, the syntax is the same as for array literals: function velocity($dist, $time) return $dist / $time; echo velocity(100, 4); // 25 echo velocity('time' => 4, 'dist' => 100); // 25Along with traditional callbacks (string and array), there's also direct reference form (Class->method or Namespace::method): echo [1, 2, 3]->map('someFunc'); // as in php echo [1, 2, 3]->map([$someObj, 'someMethod']); // as in php class SomeClass { function staticFunc($z) return $z * 10; } echo [1, 2, 3]->map(SomeClass->staticFunc); // 10,20,30Function parameters are stored in arguments array: function baz() echo arguments->reverse()->join(); baz('a', 'b', 'c'); // cbacall and call_array invoke given function (like call_user_func...): function bar() return 'hi'; call('bar');apply($func, $obj) and apply_array($func, $obj) call a function in context of object $obj, i.e. $obj temporary becomes $this in the function: class A { function info() puts '***' . $this->whoami(); function whoami() return "object A"; } class B { var $bar = '123'; function whoami() return "object B, bar={@bar}"; } $a = new A; $a->info(); // calls A->whoami $b = new B; apply($a->info, $b); // calls B->whoaminamespacesnamespace Foo { body }Namespace body can contain constant, function and class declarations. Qualified name is looked for in that namespace: echo Foo::bar();Unqualified name is looked for in current namespace and then globally. global is a namespace and can be referred as such: echo global::foo;import import from imports another namespace in the scope of current. classes@ is a shortcut for $this-> class A { function __construct($t) @wow = $t + 1; } echo (new A(125))->wow; // 126In general, -> refers to a class or object, and :: is used for namespaces. For php compatibility, it's also possible to use :: with global classes. class GlobClass { var $foo = 10; } echo GlobClass::foo; echo GlobClass->foo; // the same namespace Foo { class Bar { static $prop; ... } } echo Foo::Bar->prop;extends accepts qualified class names: class Foo extends OtherNamespace::BarConstants are resolved at run-time, that is, arbitrary expressions are allowed on the right: const X = foo() + bar();Getters and setters: class Circle { var $r; function __construct($radius) @r = $radius; function get area() return 3.1459 * @r * @r; function set area() throw 'cannot set area directly'; } $c = new Circle(10); echo $c->area; $c->area = 111;__construct can return a value. If a non-null is returned, it will be taken as the value of "new". class GoodFella {} class Person { function __construct($name) { if($name == 'Joe') return new GoodFella($name); } } echo new Person('Tom'); // (object Person) echo new Person('Joe'); // (object GoodFella)php interactionAll php functions (system and user) are automatically available to PiHiPi. PiHiPi identifiers take precedence over php ones, to use php function in any case prepend its name with php:: puts htmlspecialchars($var); // call php function function mysql_connect() {...} mysql_connect(); // call my function php::mysql_connect(); // call php functionYou can also embed 'raw' php code using 'unparsed input' brackets {< ... >}: {< # php code $html = strip_tags($_GET['msg']); >}standard librarySome of php standard library functions are rewritten in PiHiPi style: each function group is either moved to its own namespace or becomes object-oriented: // in php: echo strlen... echo str::len('ABC'); // in php: preg_replace... $text = str::replace($html, `<.*?>`, ''); // in php: fopen/fread $f = new File('foo'); $first_10 = $f->read(10); // in php: strtotime/date echo (new Date('+10 days'))->string('d M Y');Here's a brief example that should give you a better idea on what PiHiPi programming looks like. MAX_LEN) throw "text is too long"; echo "text statistics {new Date}"; $chars = []; $words = []; foreach(str::split($text) as $chr) { if($chr =~ `[A-Z]`i) { $chr = str::upper($chr); $chars[$chr] = isset $chars[$chr] ? $chars[$chr] + 1 : 1; } } if(!$chars->count()) throw "no letters in text"; echo " Letters by frequency: "; echo $chars->arsort()->keys()->join(); foreach(str::match($text, `[A-Z]+`i) as $w) { $w = str::upper($w); if(isset $words[$w]) $words[$w][1]++; else $words[$w] = [$w, 1]; } function sort_words($a, $b) return $b[1] <=> $a[1] || $a[0] <=> $b[0]; echo " Words by frequency: "; foreach($words->sort('sort_words') as $w) echo $w->join ('='), ' '; } catch($e) { puts "Error: $e"; } } echo """ I Love You Love Me Love """; ?>missing php featuresgoing to be implemented: eval and dynamic includes binary arithmetic php5 OOP extensions (public, abstract, interface and friends) references (syntax only) going to be dropped from the language: ${...} syntax backticks as shell_exec 'alternative syntax' 'declare' [Less]

0USERS
 

INC is an object-oriented low-level programming language. Designed to be a modern replacement for languages on the C level, it will provide access to the lowest level of the architecture, and a high-level interface based on modern language concepts.