Skip to content

java 1.0-SNAPSHOT #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# Java
Java version of SimplePEG

Using example:

String grammar = "GRAMMAR url\n" +
"\n" +
"url -> scheme \"://\" host pathname search hash?;\n" +
"scheme -> \"http\" \"s\"?;\n" +
"host -> hostname port?;\n" +
"hostname -> segment (\".\" segment)*;\n" +
"segment -> [a-z0-9-]+;\n" +
"port -> \":\" [0-9]+;\n" +
"pathname -> \"/\" [^ ?]*;\n" +
"search -> (\"?\" [^ #]*)?;\n" +
"hash -> \"#\" [^ ]*;";

RuleProcessor rp = new RuleProcessor(SpegParser.createAndExec(grammar));

System.out.println(rp.check("https://simplepeg.github.io/"));
System.out.println(rp.check("https://google.com/"));
System.out.println(rp.check("https://abcdssss.....com/"));

32 changes: 32 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>ru.dude</groupId>
<artifactId>SimplePEG-Java</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
</dependency>
</dependencies>

<build>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
18 changes: 18 additions & 0 deletions src/main/java/ru/dude/simplepeg/Executable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ru.dude.simplepeg;

import ru.dude.simplepeg.entity.PegNode;
import ru.dude.simplepeg.entity.State;

/**
* For implements in PEG expression
* Created by dude on 29.10.2017.
*/
public interface Executable {

/**
* Execute PEG expression
*
* @return
*/
PegNode exec(State state);
}
10 changes: 0 additions & 10 deletions src/main/java/ru/dude/simplepeg/HelloWorld.java

This file was deleted.

Loading