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

Allow identifiers to be quoted in parsing #64

Open
wisnesky opened this issue Oct 11, 2018 · 11 comments
Open

Allow identifiers to be quoted in parsing #64

wisnesky opened this issue Oct 11, 2018 · 11 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@wisnesky
Copy link
Contributor

example:

typeside Ty = literal {
types
int
string
constants
"100" "150" "200" "250" "300" : int
"115-234" "112-988" "198-887" Smith Jones "250" "300" "100"
}

@wisnesky
Copy link
Contributor Author

It turns out this isn't quite right - here's a counterexample that runs in aql-java:

typeside Ty = literal {
types
int
string
constants
"100" "150" "200" "250" "300" : int
"115-234" "112-988" "198-887" Smith Jones Sue Alice Bob : string
options
allow_empty_sorts_unsafe = true
}

@wisnesky wisnesky reopened this Oct 20, 2018
@marcosh
Copy link
Contributor

marcosh commented Oct 22, 2018

@wisnesky it looks like it is the - breaking the parser. Should it be an allowed character for identifiers? Should it be allowed only if the identifier is quoted?

At the moment the only non-alphanumeric characters allowed for identifiers are _ and $. Is there any other character which should be allowed?

@wisnesky
Copy link
Contributor Author

wisnesky commented Oct 22, 2018 via email

@wisnesky
Copy link
Contributor Author

Here's another case that breaks, actually, with or without the quotes around the 1.

options
prover = program
program_allow_nontermination_unsafe = true
allow_empty_sorts_unsafe = true
timeout = "1"

wisnesky added a commit that referenced this issue Oct 26, 2018
…ed-in-parsing

allow any character (except `"`) in quoted identifiers #64
@wires wires added this to Backlog in First Release Oct 29, 2018
@wires wires moved this from Backlog to In progress in First Release Oct 29, 2018
@wires wires added the good first issue Good for newcomers label Oct 29, 2018
@wisnesky
Copy link
Contributor Author

Can we make it so that numerals don't need to be quoted? Here's the example that should run but doesn't:

instance I = literal : S {
         generators e : E
         options timeout = 1
}

@marcosh
Copy link
Contributor

marcosh commented Nov 15, 2018

this should not be hard. But, just to make sure, do we really want that any identifier could be a numeral? This would mean that any variable, foreign key, entity, ..., could be called 23. Is this what we really want or do we need to make some distinctions? If this is the case, which is this distinction?

@wisnesky
Copy link
Contributor Author

wisnesky commented Nov 15, 2018 via email

@wisnesky
Copy link
Contributor Author

wisnesky commented Nov 15, 2018 via email

@wisnesky
Copy link
Contributor Author

It may seem silly to allow "42" to be the name of an entity/fk/att/etc, but ok to allow "42" to be name of a constant symbol. But in fact, because AQL users can do things like pivot (convert rows to columns), you can easily get in to circumstances where 42 is an entity/fk/att/etc.

@marcosh
Copy link
Contributor

marcosh commented Nov 16, 2018

I started out replicating the logic of the symbol parser in the antlr definition, but that seems to be not what it's actually needed

@wisnesky
Copy link
Contributor Author

On closer inspection, Fred's ANTLR file is hit or miss. It handles

typeside t = empty
schema s = empty : t
instance I = literal : s {
         options timeout = 1
} 

correctly but doesn't handle

instance J = literal : empty : empty {
} 

Ground truth is in the java jparsec parser: https://github.com/CategoricalData/fql/blob/1f7bc30cfaff8d499b301ca5b52a492c0c934a4e/src/main/java/catdata/aql/exp/CombinatorParser.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
First Release
  
In progress
Development

No branches or pull requests

4 participants