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

構文カテゴリが「それですべて」であることをどうやって知るのか #1115

Open
Seasawher opened this issue Nov 16, 2024 · 2 comments
Labels

Comments

@Seasawher
Copy link
Member

Seasawher commented Nov 16, 2024

aesop の phase や builder_name が「それですべて」であることを保証したい

declare_syntax_cat hoge_cat

syntax "hoge" : hoge_cat
syntax "fuga" : hoge_cat
syntax "foo" : hoge_cat

Zulip: >
how to enumerate all syntax of given sytanx category

@Seasawher
Copy link
Member Author

Seasawher commented Nov 16, 2024

syntax category は拡張可能なので、全列挙することはできない。(「これですべて」という情報がない)
また TSyntax は正当性をチェックしないので、固定された構文でも全列挙は保証できない。

何が入っているのかを列挙することは一応できる。

declare_syntax_cat hoge_cat

syntax "hoge" : hoge_cat
syntax "fuga" : hoge_cat
syntax "foo" : hoge_cat

open Lean

def matchHogeCat : TSyntax `hoge_cat → Unit
  | `(hoge_cat| hoge) => ()
  | `(hoge_cat| fuga) => ()
  | `(hoge_cat| foo) => ()
  | _ => () -- why this line is needed? Without this line, the match is said not to be exhaustive.

@Seasawher
Copy link
Member Author

構文カテゴリを使うからだめ。<|> を使うべき。

syntax hoge := "hoge" <|> "fuga" <|> "foo"

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

No branches or pull requests

1 participant