Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to include untagged remarks into parse tree and formatter output #64

Open
zakjan opened this issue Feb 11, 2021 · 2 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@zakjan
Copy link
Contributor

zakjan commented Feb 11, 2021

The challenge is that Express formatting is different between original and formatted code. I'll probably need to introduce some sort of attach points where untagged remarks can attach to (e.g. after each item in a list). With this approach, slight variances would still be possible.

@zakjan zakjan self-assigned this Feb 11, 2021
@zakjan zakjan changed the title Research the ability to include untagged remarks into parse tree and formatter output Ability to include untagged remarks into parse tree and formatter output Feb 11, 2021
@zakjan zakjan added the enhancement New feature or request label Feb 15, 2021
@zakjan
Copy link
Contributor Author

zakjan commented Feb 16, 2021

Probably depends on #65, because it can clarify what are expected attach points.

@ronaldtse
Copy link
Contributor

We need to parse untagged remarks and also include it in the output of Formatter.

e.g.

action_schema.exp

(*
$Id: action_schema.exp,v 1.36 2021/05/06 16:23:00 kevin Exp $
ISO 10303 TC184/SC4/WG12 N10693

EXPRESS Source:
ISO 10303-41 ed7 Fundamentals of product description and support - Action schema

The following permission notice and disclaimer shall be included in all copies of this EXPRESS schema ("the Schema"), 
and derivations of the Schema:
...
*)

SCHEMA action_schema '{iso standard 10303 part(41) version(9) object(1) action_schema(1)}';
  REFERENCE FROM basic_attribute_schema (	-- ISO 10303-41
    description_attribute, 
    description_attribute_select,
    get_description_value, 
    get_id_value, 
    get_name_value,
    get_role, 
    id_attribute, 
    id_attribute_select,
    name_attribute,
    name_attribute_select,
    object_role,
    role_select,
    role_association);
    
  REFERENCE FROM support_resource_schema ( -- ISO 10303-41
    bag_to_set, 
    identifier, 
    label, 
    text);

The first part:

(*
$Id: action_schema.exp,v 1.36 2021/05/06 16:23:00 kevin Exp $
ISO 10303 TC184/SC4/WG12 N10693
...
*)

This is an "untagged remark" because a "tagged remark" is attached to an object and looks like this:

(*"object_name.xxx"
...
*)

Right now Expressir is not rendering the untagged remarks.

For example:
In iso-10303-srl:

exp_file = "schemas/resources/action_schema/action_schema.exp"
repository = Expressir::Express::Parser.from_files([exp_file])
formatter  = Class.new(Expressir::Express::Formatter) do
    def format_remark(node, remark)
      [
        [
          '(*',
          '"',
          node.path || node.id,
          '"',
        ].join(''),
        remark,
        '*)'
      ].join("\n")
  end
end

puts formatter.format(repository)

This gives you the pretty formatted version but without the untagged remark (the tagged remarks exist)

SCHEMA action_schema '{iso standard 10303 part(41) version(9) object(1) action_schema(1)}';

REFERENCE FROM basic_attribute_schema
  (description_attribute,
   description_attribute_select,
   get_description_value,
   get_id_value,
   get_name_value,
   get_role,
   id_attribute,
   id_attribute_select,
   name_attribute,
   name_attribute_select,
   object_role,
   role_select,
   role_association);
...
(*"action_schema"
...
*)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants