Store whether a state accepts, not whether it drops

This commit is contained in:
josh committed 2023-07-08 08:29:33 -04:00
1 parent 8a377b4950
commit c88338698a
4 files changed
+7 -24

No files matched your search

+1 -1
View File
@@ -148,7 +148,7 @@ class Propane
end
consume!(/\s+/)
consume!(/;/, "expected `;'")
@patterns << Pattern.new(pattern: pattern, line_number: @line_number, drop: true, mode: @mode)
@patterns << Pattern.new(pattern: pattern, line_number: @line_number, mode: @mode)
@mode = nil
true
end
+1 -2
View File
@@ -24,7 +24,6 @@ class Propane
}
states = mode_info[:dfa].enumerate
states.each do |state, id|
drop = state.accepts && state.accepts.drop?
token =
if state.accepts && state.accepts.token
state.accepts.token.id
@@ -36,7 +35,7 @@ class Propane
state_table << {
transition_table_index: transition_table.size,
n_transitions: state.transitions.size,
drop: drop,
accepts: !!state.accepts,
token: token,
code_id: code_id,
}
-11
View File
@@ -40,8 +40,6 @@ class Propane
# Optional parameters.
# @option options [String, nil] :code
# Code block to execute when the pattern is matched.
# @option options [Boolean] :drop
# Whether this is a drop pattern.
# @option options [String, nil] :pattern
# Pattern.
# @option options [Token, nil] :token
@@ -52,7 +50,6 @@ class Propane
# Lexer mode for this pattern.
def initialize(options)
@code = options[:code]
@drop = options[:drop]
@pattern = options[:pattern]
@token = options[:token]
@line_number = options[:line_number]
@@ -63,14 +60,6 @@ class Propane
@nfa = regex.nfa
end
# Whether the pattern is a drop pattern.
#
# @return [Boolean]
# Whether the pattern is a drop pattern.
def drop?
@drop
end
end
end