Change precedence level meaning + update TODO

This commit is contained in:
Robin Jadoul 2017-01-27 16:18:58 +01:00
parent 4b14e6ac37
commit bd45f47c47
3 changed files with 9 additions and 8 deletions

11
TODO
View File

@ -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

View File

@ -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;

View File

@ -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;