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

Generalize matching #226

Closed
flbulgarelli opened this issue Feb 4, 2019 · 5 comments
Closed

Generalize matching #226

flbulgarelli opened this issue Feb 4, 2019 · 5 comments

Comments

@flbulgarelli
Copy link
Member

It would be nice that we were able to use inspections inside inspections.

Something like:

within pepita assigns energia that uses literal 0
within program calls * that uses arithmetic
within program not declares class * that uses if

This feature is the natural next-step to #225, since

within pepita assigns energia with 0 == within pepita assigns energia that is literal 0
@flbulgarelli flbulgarelli mentioned this issue Feb 4, 2019
4 tasks
@flbulgarelli
Copy link
Member Author

flbulgarelli commented Feb 4, 2019

Some proposed new inspections that we should implement are:

  • usesLiteral
  • usesArithmethic
  • usesSelf
  • isSelf

@flbulgarelli
Copy link
Member Author

The problem with this issue is that it will become really difficult to express the inspections using the current : format, because it may involve complex nesting:

within voladores declares pepita that (within volar not uses if)   

So we will need to accept at least one of the following:

A more complex json structure:

{ 
  intransitive: bool,
  scope: ("*" | string),
  negated: bool,
  verb: string,
  target: string,
  matcher: { with: string  } | { that: expectation } | { thatAll: [expectation] } | { thatAny: [ expectation] }
  }

A more natural-language-like syntax

expectation :== intransitive? within <scope>? not? <humanized verb> <target>?  [that <expectation> | with <literals> | that all <expectations> | that any <expectations> ]?

@flbulgarelli
Copy link
Member Author

flbulgarelli commented Feb 4, 2019

Also, we will need to generalize arguments-passing to verbs, in order to be able to create assertions like

uses literal 5
has arity N 

@flbulgarelli
Copy link
Member Author

Also, we should create new versions for many of the existing inspections, i.e:

-- | Inspection that tells whether an expression uses ifs
-- in its definition
usesIf :: Inspection
usesIf = unmatching usesIfMatching

usesIfMatching :: Matcher -> Inspection
usesIfMatching matcher = containsExpression f
  where f (If cond true false) = matcher [true, cond, false]
        f _                    = False

@flbulgarelli
Copy link
Member Author

Fixed by #241

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