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

Improve parsing algorithm to handle spaces and comments #63

Closed
xonixx opened this issue Oct 5, 2021 · 0 comments
Closed

Improve parsing algorithm to handle spaces and comments #63

xonixx opened this issue Oct 5, 2021 · 0 comments
Assignees
Milestone

Comments

@xonixx
Copy link
Owner

xonixx commented Oct 5, 2021

Things to take into account

  1. Support comments in @directive lines and spaces in goal names
  2. We need to rely on quoting 'str' or "str"
  3. It's desirable that whatever quoting approach we chose it plays nice with shell's quoting:
    • The shell highligting applied to Makesurefile in IDE keeps working.
    • You can take the goal name as rendered by ./makesure -l and use it to call ./makesure 'goal name'
    • However to implement the whole shell-compliant parsing for 'all' "types" of $'strings' will be too complex.
  4. Need to handle '\'' properly and consistently.
  5. Complications with @doc and @define

Comments

@goal goal_with_comment # comment
  echo goal_with_comment

@goal test1
@depends_on goal_with_comment

This one won't parse as expected. # comment will be treated as part of goal name

Spaces

@goal @glob 22_parsing*.txt # glob can produce files with whitespaces in the name
  echo "$ITEM"
  cat "$ITEM"

@goal test2
@depends_on '22_parsing 2.txt' # but currently this is impossible

Right now we rely on default AWK algorithm at parsing a line (NF + $i). This is totally fine for current version since covers most of cases, but we need something more flexible.

Possible approach

@goal no_space

@goal 'name with spaces' # no single quote allowed between single quotes

@goal $'name with \' quote' # $'strings' allow quote escaping 

./makesure -l

Available goals:
  no_space
  'name with spaces'
  $'name with \' quote'

Rationale

  • Why support both 'str' and $'str'
    • most of the time 'str' can be used, rarely $'str\'str'
  • Why not "str\"\'str"
    • this implies unneded variables substitution. I.e. ./makesure "aaa$bbb" will not work as expected.
@xonixx xonixx self-assigned this Oct 5, 2021
@xonixx xonixx added this to the 0.9.12 milestone Oct 5, 2021
@xonixx xonixx closed this as completed Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant