Commit graph

7457 commits

Author SHA1 Message Date
overflowerror
b9b7bf18a0 made ecore model portable 2022-02-02 17:16:28 +01:00
overflowerror
e00d86eb1c removed loop progress exceptions and endless loop shortcut
there is no need to throw an exception if a loop has no progress -> it
can be skipped

fixed bug with merge() in TokenAnalysisPaths: merging with empty path is
an identity operation but further merged with the same path cause
problems because of concurrent modifications in the LinkedHashSet
2022-02-01 17:06:25 +01:00
overflowerror
3af9fd0c4a potential fix for endless loop
check progress on smallest branch in every iteration not just the first
-> now loops in token analysis should always exit, either by being done
or by tripping the endless loop protection
2022-02-01 15:55:50 +01:00
overflowerror
b7f69d8a65 cleanup in HoistingProcessor and TokenAnalysis 2022-01-28 21:51:13 +01:00
overflowerror
47075708d6 disabled benchmark test case 2022-01-28 20:41:16 +01:00
overflowerror
76f580ad0c optimized console output
console output is now hidden behind debug flag
2022-01-28 20:38:47 +01:00
overflowerror
0e26c5fccf fixed missing cardinality in debug utils output 2022-01-28 20:22:02 +01:00
overflowerror
e2984ad177 added benchmark for hoisting & fixed caching
use path in grammar as key for caching elements; using the elements
itself doesn't work because the reference will be different for the
content assist grammar run.
this does not work for generated elements; the only place that generated
elements are necessary is when dealing with nested identical paths, in
this case caching is disabled.

the benchmark test case does not validate the result since we are only
interested in the runtime.
2022-01-28 20:18:35 +01:00
overflowerror
dc950e4bef clean up of findGuardForGroup in HoistingProcessor
removed special case for non-trivial cardinality - use regular
findGuardForElement instead

adjusted test cases to follow antlr semantic - ignore following
predicates

made HoistingProcessor Singleton

preparation for better caching
2022-01-28 19:57:30 +01:00
overflowerror
00ff0407b0 added tests for hoisting specific renders
tests predicate rendering in alternatives, in non-trivial cardinalities,
and setup block rendering. in both the production grammar and content
assist grammar.

added debug grammar generators for production grammar and content assist
grammar which use DebugGrammarNaming to avoid null-ptr because of
missing adapters in ecore objects. (existing AntlrDebugGrammarGenerator
can't be used because setup blocks are handled by AntlrGrammarGenerator
and AntlrContentAssistGrammarGenerator respectively, not
AbstractAntlrGrammarGenerator.)

fixed small details in rendered output (removed guard of rule comment
and trimmed setup block).
2022-01-27 20:37:07 +01:00
overflowerror
07845a3590 fixed empty recursion paths in context analysis
- added test case of recursive rules (with start rule) and optional
context
- disable cardinalities (and repetitions in unordered groups) in context
analysis if the current element was already seen and there was no
progress this recursion - the element itself will not be returned by
getNextElementsInContext()
- changed isStartRule() and findAllRuleCalls() in GrammarUtils to only
compare the name of the rule. otherwise constructed paths cause problems
(since the rule object is not the same and the alternatives-attribute
might (very probably) not be equal in the constructed rule object).
- changed findGuardForOptionalCardinalityWithoutContext() in
HoistingProcessor to avoid the construction of virtual elements and
instead provide the virtual cardinality to the token analysis via a new
parameter.
- fixed testCardinalityQuestionmarkWithExternalContext_expectContextCheck()
test case (context analysis is not possible if the context equals the
remainder of the prefixed alternative; changed context to be different)
2022-01-22 22:02:09 +01:00
overflowerror
cc8eb0a7da fixed problem with antlr content assist grammar generator
predicates in non-trivial cardinalities are not hoisted

fix: render hoisting guard in content assist grammar generator.
2022-01-20 18:18:32 +01:00
overflowerror
2cd6e454d7 fixed problem with empty paths in token analysis
empty paths are keep the state of the prefix including the empty flag
which causes empty paths in alternatives to be lost.

fix: create new token state with prefix (reset empty flag)
2022-01-20 14:26:40 +01:00
overflowerror
aad95fa670 fixed problem with repeated empty paths in context
no-progress-in-loop-error is interpreted as nested identity paths - this
is wrong

fix: enable endless loop shortcut in context analysis
2022-01-20 14:00:32 +01:00
overflowerror
9dfc0b4bfc fixed problem with tail-recursion in context analysis
recursive (only tail recursion) causes problems because context of rule
call causes endless recursion in getNextElementsInContext()

example:

S: {S} $$ p0 $$?=> 's'
 |     $$ p1 $$?=> 's' s=S
;

solution: added set of visited rule calls to parameter list, skip rule
call if it was already handled by another recursion

added test cases
2022-01-18 17:15:45 +01:00
overflowerror
9c6b8673d0 changed 'static' keyword to 'setup' 2022-01-18 15:43:03 +01:00
overflowerror
87d5b57f62 fixed grammar attributes (debug, token limit) not being set
attributes are not set when generating flattened grammar access

fix: explicitly copy attributes to flattenedGrammar
2022-01-18 14:31:54 +01:00
overflowerror
7f10364f08 get debug and token limit from ecore model
moved default token limit to ecore model
2022-01-17 17:13:57 +01:00
overflowerror
2deeea0bd5 added hoisting debug and tokenLimit settings to grammar definition 2022-01-17 16:51:04 +01:00
overflowerror
e317d65b45 added token limit & debug flag to grammar ecore model 2022-01-16 18:22:19 +01:00
overflowerror
623f4b69ae fixed endless recursion in context analysis
when context analysis is needed and an element in context has multiple
cardinality and contains empty paths (e.g. ?-quantified) the quantified
element will be recursed endlessly without the token analysis path even
being done (since there is always an empty path) - this also applies to
unordered groups.

recognizing empty paths is not trivial because of recursive rules.

solution: save "call stack" (actually just a set of visited elements)
during recursions in context analysis. if an element is seen multiple
times we check if there is any progress in the analysis paths. if not
this is an endless recursion
-> throw exception
2022-01-15 16:56:09 +01:00
overflowerror
a1b9bb9a59 added test cases for cardinalities in context
see a5df42591b
2022-01-15 15:31:27 +01:00
overflowerror
a5df42591b fixed problem with context analysis
non-trivial quantifiers in context path are not handled correctly.

change to getNextElementsInContext():
add non-trivially quantified elements in path (except first element
because of potential endless recursion) to result set
2022-01-14 17:22:15 +01:00
overflowerror
e5f08c34aa fixed bug in context analysis
when the following context element is optional, the minimal sequence is
not going to get bigger. in this case further context analysis is
blocked by the exception.
=> removed exception

also made sure getNextElementsInContext() won't return non-token,
non-compound elements like actions or predicates.
2022-01-11 22:07:33 +01:00
overflowerror
edbc920247 changed token limit for tree rebuild
is necessary because otherwise the identity analysis might not be able
to detect if paths are identical up to the token limit (which should
cause an error)
2022-01-07 20:44:36 +01:00
overflowerror
8fac71dda9 added comment to failing test case
testRecursiveRuleCallingAlternative_expectCorrectGuard

guard for nested alternatives might not be optimal if the positions that
discriminate in the first alternatives is different from the positions
needed on the next one
2021-12-25 16:41:19 +01:00
overflowerror
428dfb93d0 fixed path collapse
collapsed paths loose the containing token guard
=> fixed problem
+ added positional condition in token sequence guard constructor to not
check positions twice (order matters: give local token guard first in
case it is sufficient)

removed testNestedAlternativesWithSingleTokenDifference, because it is
wrong: 'a' 'b' 'd' with p1 satisfies semantic predicates but not the
generated guard condition
2021-12-25 16:10:54 +01:00
overflowerror
a83e3627cc disabled recursive debugging outputs for testing 2021-12-23 18:25:30 +01:00
overflowerror
ebef309674 fixed problem with unordered groups and non-trivial cardinalities in
nested prefix alternatives analysis

now flattenPaths() considers following repetitions

new problem: unordered groups and non-trivial cardinalities without
non-optional elements causes explosion of generated alternatives, which
in turn cause the identity analysis to go out of control
example: S: ('a'? | 'b'?)+
with a token limit of 10 the nested prefix alternatives analysis would
generate over 1300 alternatives

current quick fix: limit of alternatives
2021-12-23 18:13:52 +01:00
overflowerror
36f790b37b fixed test cases concerning identical paths and nested prefix paths 2021-12-17 21:59:00 +01:00
overflowerror
2726ec0e09 removed unnecessary parenthesis from rendered output 2021-12-17 21:52:25 +01:00
overflowerror
be80d5ffbc added basic support for nested prefix alternatives
after minimal path difference analysis failed, flatten paths (limited by
token limit; justification: identity check would error out if paths are
not distinguishable within the limit) and recompute alternative guard.
now nested prefixes will be collapsed with all corresponding guard
conditions
2021-12-17 21:18:59 +01:00
overflowerror
45d2df5c33 fixed uninitialized hoisting processer
moved init before generateFile
used flattenedGrammar instead of original grammar (it)
2021-12-14 15:13:35 +01:00
overflowerror
94a3601dff fixed identical path analysis to consider prefixes 2021-12-13 16:58:10 +01:00
overflowerror
d8ee388b31 basic support for context analysis in unordered groups 2021-12-10 17:33:28 +01:00
overflowerror
08b240eed4 added more test cases for context analysis 2021-12-09 19:43:05 +01:00
overflowerror
0a6b1b69c9 added support for context analysis with optional cardinalities
unordered groups not yet working properly
2021-12-09 19:30:19 +01:00
overflowerror
d2c6a46071 fixed context analysis not able to see context tokens
added toString methods in guard classes for debugging
2021-12-08 20:17:15 +01:00
overflowerror
372d0a4a01 basic support for simple prefix paths 2021-12-08 18:45:54 +01:00
overflowerror
621f37874f changed terminal token condition to use LA syntax 2021-12-07 18:55:01 +01:00
overflowerror
8d34bc2a23 fixed non-optimal guard with nested groups
nested groups produce non-optimal guard (redundant parentheses)
-> group guard now adds elements of groups instead of the group itself

added test case
2021-12-05 18:31:57 +01:00
overflowerror
83232e5a43 fixed bug with alternatives containing unordered groups
gave exception in token analysis
-> added handling for unordered groups to token analysis

added test case
2021-12-05 18:18:18 +01:00
overflowerror
13aef9e99b fixed problem with unsupported constructs in unguarded rules 2021-12-04 18:36:50 +01:00
overflowerror
62e9d44a64 added SynStateTypes for semantic predicates and java actions 2021-12-04 18:13:23 +01:00
overflowerror
0ad55d42cc render predicates for non-trivial-cardinalities 2021-12-04 18:03:41 +01:00
overflowerror
1058d2bf3c changed unordered group hoisting to just use + instead
cardinality * is only possible if all element in the unordered group are
optional. This case doesn't matter for hoisting or rather is already
dealt with in the containing group (the guard of the resulting
alternatives won't have a terminal).
2021-12-04 17:28:45 +01:00
overflowerror
1d4b649755 hoisting in unordered groups uses one or more cardinality if it contains
non-optional elements

TODO: fix special case in anlternatives hoisting
2021-12-02 21:36:05 +01:00
overflowerror
2303cce7c4 added hoisted predicates to unordered group rendering 2021-12-02 21:21:16 +01:00
overflowerror
f23274e072 fixed problem with clone method by using EcoreUtil.copy instead 2021-12-02 21:19:27 +01:00
overflowerror
b3e48838f3 changed grammar generator to not render gated semantic predicates 2021-12-02 20:37:13 +01:00