forked from vadyushkins/kotgll
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* replace handwriteParser to test folder * Refactor rsmState, extraction of terminal and nonterminal edges from the state is made faster * Add hand-write "generated" parsers * Add state id for generation, refactor parsers code * simple refactoring * add simple kotlinpoet example * add simple generated parsers * minor refactoring: * replace getRsm method to rsm property * replace parser exception to parser directory * done base parser generator * done dynamic test system for online gll * refactor test directory structure * generate and compile parser class * refactor tests directory * refactor tests generator
- Loading branch information
Showing
37 changed files
with
873 additions
and
138 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,3 +79,4 @@ bin/ | |
|
||
### Mac OS ### | ||
.DS_Store | ||
/src/test/resources/gen/parser/ |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.srcgll | ||
|
||
import java.util.* | ||
|
||
fun <ElementType> incrementalDfs( | ||
startElementL: ElementType, | ||
next: (ElementType) -> Iterable<ElementType> | ||
): HashSet<ElementType> { | ||
val used = HashSet<ElementType>() | ||
val queue = LinkedList<ElementType>() | ||
queue.add(startElementL) | ||
while (queue.isNotEmpty()) { | ||
val element = queue.remove() | ||
used.add(element) | ||
for (nextElement in next(element)) { | ||
if (!used.contains(nextElement)) { | ||
queue.add(nextElement) | ||
} | ||
} | ||
} | ||
return used | ||
} | ||
|
||
fun <CollectionType, ElementType> incrementalDfs( | ||
startElementL: ElementType, | ||
next: (ElementType) -> Iterable<ElementType>, | ||
collection: CollectionType, | ||
addToCollection: (ElementType, CollectionType) -> Unit | ||
): CollectionType { | ||
val used = HashSet<ElementType>() | ||
val queue = LinkedList<ElementType>() | ||
queue.add(startElementL) | ||
while (queue.isNotEmpty()) { | ||
val element = queue.remove() | ||
used.add(element) | ||
addToCollection(element, collection) | ||
for (nextElement in next(element)) { | ||
if (!used.contains(nextElement)) { | ||
queue.add(nextElement) | ||
} | ||
} | ||
} | ||
return collection | ||
} | ||
|
||
|
||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
...org/srcgll/exceptions/ParsingException.kt → ...lin/org/srcgll/parser/ParsingException.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.srcgll.exceptions | ||
package org.srcgll.parser | ||
|
||
class ParsingException(msg: String = "Parsing exception") : Exception(msg) { | ||
} |
Oops, something went wrong.