Allow user to terminate the parser - close #13

This commit is contained in:
josh committed 2024-01-03 22:32:10 -05:00
1 parent 92c76b74c8
commit 24af3590d1
8 files changed
+162 -14

No files matched your search

+15 -1
View File
@@ -200,7 +200,12 @@ class Propane
end
if parser
code = code.gsub(/\$\$/) do |match|
"_pvalue.v_#{rule.ptypename}"
case @language
when "c"
"_pvalue->v_#{rule.ptypename}"
when "d"
"_pvalue.v_#{rule.ptypename}"
end
end
code = code.gsub(/\$(\d+)/) do |match|
index = $1.to_i
@@ -211,6 +216,15 @@ class Propane
"statevalues[$-1-n_states+#{index}].pvalue.v_#{rule.components[index - 1].ptypename}"
end
end
code = code.gsub(/\$terminate\((.*)\);/) do |match|
user_terminate_code = $1
case @language
when "c"
"context->user_terminate_code = (#{user_terminate_code}); return P_USER_TERMINATED;"
when "d"
"context.user_terminate_code = (#{user_terminate_code}); return P_USER_TERMINATED;"
end
end
else
code = code.gsub(/\$\$/) do |match|
case @language