Change precedence level meaning + update TODO
This commit is contained in:
parent
4b14e6ac37
commit
bd45f47c47
11
TODO
11
TODO
|
@ -1,11 +1,7 @@
|
|||
-----------------------------------------------------------------------
|
||||
- TODO -
|
||||
-----------------------------------------------------------------------
|
||||
K> Parsodus Parsodus parser
|
||||
-> Precedence + fill precedence in rules
|
||||
-> rule naming (problem: multiple rules same name -> change in backend)
|
||||
-> grammar struct change to contain optional name per rule
|
||||
-> Volgorde belangrijk?
|
||||
K> Reading terminals from lexesis + checking for unknown symbols
|
||||
-> Voorbeelden
|
||||
-> brainfuck? bare bones? bash transpiler?
|
||||
R> simple calculator
|
||||
|
@ -35,6 +31,11 @@ R> JSON port -> rewrite once named rules exist
|
|||
-----------------------------------------------------------------------
|
||||
- DONE -
|
||||
-----------------------------------------------------------------------
|
||||
K> Parsodus Parsodus parser
|
||||
-> Precedence + fill precedence in rules
|
||||
-> rule naming (problem: multiple rules same name -> change in backend)
|
||||
-> grammar struct change to contain optional name per rule
|
||||
-> Volgorde belangrijk?
|
||||
-> logging
|
||||
-> write configuration sets, table
|
||||
-> Generator: logging
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace pds {
|
|||
std::set<std::string> variables; ///< the variables
|
||||
std::set<std::string> terminals; ///< the terminals
|
||||
std::deque<std::shared_ptr<Rule>> rules; ///< the replacement rules
|
||||
std::map<std::string, std::pair<int, PrecedenceType> > precedence; ///< lower value -> higher precedence
|
||||
std::map<std::string, std::pair<int, PrecedenceType> > precedence; ///< higher value -> higher precedence
|
||||
|
||||
std::unique_ptr<util::FirstSet> first;
|
||||
std::unique_ptr<util::FollowSet> follow;
|
||||
|
|
|
@ -141,10 +141,10 @@ LRTable Generator<Itemset>::generate() {
|
|||
auto rightTokenIt = m_gram.precedence.find(term);
|
||||
if (m_gram.rules[rule_applied]->precedence.first && rightTokenIt != m_gram.precedence.end()) {
|
||||
auto& leftPrec = m_gram.rules[rule_applied]->precedence.second;
|
||||
if (leftPrec.first > rightTokenIt->second.first) {
|
||||
if (leftPrec.first < rightTokenIt->second.first) {
|
||||
// Keep the shift
|
||||
handled = true;
|
||||
} else if (leftPrec.first < rightTokenIt->second.first) {
|
||||
} else if (leftPrec.first > rightTokenIt->second.first) {
|
||||
// replace with a reduce
|
||||
table.act[curIdx][term] = {Action::REDUCE, rule_applied};
|
||||
handled = true;
|
||||
|
|
Loading…
Reference in New Issue