cyk 1.0.0
context-free grammar parser
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
cyk
A context-free grammar parser using the CYK algorithm.
Usage
import std.string : split;
import cyk : CYK;
void main() {
string[] rules = [
`FunctionDeclaration → ReturnType FunctionName "(" OptionalParameters ")"`,
`ReturnType → Type`,
`Type → IntType | FloatingType | "void" | "string"`,
`IntType → "int" | "long"`,
`FloatingType → "float" | "double"`,
`FunctionName → "foo" | "bar" | "baz"`,
`OptionalParameters → Parameters`,
`OptionalParameters →`,
`Parameters → Type ParameterName | Type ParameterName "," Parameters`,
`ParameterName → "a" | "b" | "c"`
];
CYK cyk = new CYK(rules, "FunctionDeclaration");
// some valid function declarations
assert(cyk.check("double foo ( )".split));
assert(cyk.check("string bar ( int a )".split));
assert(cyk.check("void baz ( int a , float b , long c )".split));
// some invalid function declarations
assert(!cyk.check("double foo ( int )".split));
assert(!cyk.check("string ( int a )".split));
assert(!cyk.check("void baz ( int a float b , long c )".split));
}
- Registered by Jakob Kogler
- 1.0.0 released 3 years ago
- jakobkogler/cyk
- MIT
- Copyright © 2021, Jakob Kogler
- Authors:
- Dependencies:
- none
- Versions:
-
1.1.0 2021-Jan-16 1.0.2 2021-Jan-16 1.0.1 2021-Jan-16 1.0.0 2021-Jan-16 ~main 2021-Jan-16 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
15 downloads total
-
- Score:
- 0.6
- Short URL:
- cyk.dub.pm