Class: Sfp::Parser
Overview
main class which processes configuration description in SFP language either in file or as a string
Constant Summary
Constants included from SasTranslator
SasTranslator::ActivateSimpleGlobalConstraint, SasTranslator::GlobalConstraintMethod, SasTranslator::GlobalOperator, SasTranslator::GlobalVariable, SasTranslator::GoalOperator, SasTranslator::GoalVariable, SasTranslator::ImplicationToDisjunction, SasTranslator::SometimeOperatorPrefix, SasTranslator::SometimeVariablePrefix
Instance Attribute Summary collapse
-
#conformant ⇒ Object
Returns the value of attribute conformant.
-
#constraint_next_id ⇒ Object
readonly
Returns the value of attribute constraint_next_id.
-
#home_dir ⇒ Object
Returns the value of attribute home_dir.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#root_dir ⇒ Object
Returns the value of attribute root_dir.
Attributes included from SasTranslator
#axioms, #benchmarks, #goals, #operators, #types, #variables
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Parser
constructor
A new instance of Parser.
- #parse(string, options = {}) ⇒ Object
- #to_json(params = {}) ⇒ Object
Methods included from SasTranslator
#add_unknown_undefined_value_to_variables, #add_unknown_value_to_nonstatic_variables, #and_equals_constraint_to_map, #apply_global_constraint_method_1, #apply_global_constraint_method_2, #array_to_or_constraint, #break_nested_reference, #calculate_depth, #combinator, #compile_step_1, #compile_step_2, #conjunction_only, #consistent_with_and, #consistent_with_equals, #create_and_constraint, #create_equals_constraint, #create_not_constraint, #create_not_equals_constraint, #create_or_constraint, #create_output, #cross_product_and, #dump_axioms, #dump_operators, #dump_types, #dump_vars, #enforce_equals_constraint, #evaluate_set_variables_and_types, #flatten_and_or_graph, #get_list_not_value_of, #ground_procedure_parameters, #identify_immutable_variables, #is_this, next_axiom_id, next_constraint_id, next_constraint_key, next_operator_id, next_variable_id, #normalize_formula, #normalize_nested_left_only, #normalize_nested_left_right, #normalize_nested_right_only, #normalize_nested_right_only_multiple_values, #normalize_nested_right_values, #not_equals_statement_to_or_constraint, null_of, #post_support_premise, #post_threat_conclusion, #postprocess_simple_global_constraint, #postprocess_simple_global_constraint_to_operator, #pre_support_premise, #pre_threat_conclusion, #preprocess_simple_global_constraint, #process_conditions, #process_effects, #process_global_constraint, #process_goal, #process_grounded_operator, #process_operator, #process_procedure, #process_sometime, #process_sometime_after, #ref_combinator, #remove_not_and_iterator_constraint, reset_operator_id, #reset_operators_name, #sas, #search_and_merge_mutually_inclusive_operators, #set_variable_values, #simple_formulae, #substitute_template, #to_and_or_graph, #to_sas, #total_element, #variable_name_and_value, #visit_and_or_graph
Constructor Details
#initialize(params = {}) ⇒ Parser
Returns a new instance of Parser.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sfp/parser.rb', line 10 def initialize(params={}) @root_dir = (params[:root_dir].is_a?(String) ? params[:root_dir].strip : nil) @home_dir = (params[:home_dir].is_a?(String) ? params[:home_dir].strip : nil) @root = params[:root] @conformant = !!params[:conformant] @constraint_next_id = (params[:constraint_next_id] ? params[:constraint_next_id] : 0) end |
Instance Attribute Details
#conformant ⇒ Object
Returns the value of attribute conformant.
7 8 9 |
# File 'lib/sfp/parser.rb', line 7 def conformant @conformant end |
#constraint_next_id ⇒ Object (readonly)
Returns the value of attribute constraint_next_id.
8 9 10 |
# File 'lib/sfp/parser.rb', line 8 def constraint_next_id @constraint_next_id end |
#home_dir ⇒ Object
Returns the value of attribute home_dir.
7 8 9 |
# File 'lib/sfp/parser.rb', line 7 def home_dir @home_dir end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
8 9 10 |
# File 'lib/sfp/parser.rb', line 8 def root @root end |
#root_dir ⇒ Object
Returns the value of attribute root_dir.
7 8 9 |
# File 'lib/sfp/parser.rb', line 7 def root_dir @root_dir end |
Class Method Details
.parse_file(filepath, options = {}) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/sfp/parser.rb', line 43 def self.parse_file(filepath, ={}) #homedir = File.expand_path(File.dirname(filepath)) [:home_dir] = File.(File.dirname(filepath)) if ![:home_dir] parser = Sfp::Parser.new() #{:home_dir => homedir}) parser.parse(File.read(filepath)) parser.root end |
Instance Method Details
#parse(string, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sfp/parser.rb', line 23 def parse(string, ={}) lexer = SfpLang::Lexer.new(string) tokens = ANTLR3::CommonTokenStream.new(lexer) parser = SfpLang::Parser.new(tokens) parser.root_dir = @root_dir parser.home_dir = @home_dir parser.constraint_next_id = @constraint_next_id parser.sfp @constraint_next_id = parser.constraint_next_id @root = parser.root @conformant = parser.conformant @parser_arrays = parser.arrays end |