Skip to content

Conversation

Copy link

Copilot AI commented Dec 5, 2025

The previous work to remove the import mechanism inadvertently broke the external symbol mechanism. This PR cleanly separates the two:

  • Import mechanism (removed): using statements, term.using, ntrm.using for importing lexical/syntactical units from other grammar files
  • External symbol mechanism (preserved): ntrm.external for embedding other languages as symbols in the current grammar

Changes

Grammar definition (grammar/grammar.grammar)

  • Removed USING terminal, using/usings rules, term.using, ntrm.using
  • Kept ntrm.external -> ID@name ARROW STRING@grammar SEMICOLON;
  • Simplified term to single pattern (was term.define/term.using)

Grammar loader (src/aliox/grammar.cpp, include/aliox/grammar.h)

  • Added ExternalLoader callback type for loading external grammars
  • Implemented external symbol loading via syntax.Import()
using ExternalLoader = std::function<Syntax(std::string const&)>;
static Syntax Compile(Doc grammar, ExternalLoader loader);

Hardcoded syntax (generated/include/grammar/syntax.h)

  • Updated to match simplified grammar structure
  • Corrected symbol IDs and formula IDs

Build compatibility

  • Added println_compat.h for fmt < 10.0.0 compatibility

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • center2.conan.io
    • Triggering command: /home/REDACTED/.local/bin/conan conan install /tmp/conanfile.txt --output-folder=/tmp/conan_deps --build=missing (dns block)
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

在去除导入机制的工作中似乎误删除了确保外部符号机制正常工作所需的实现。请再次慎重分析仓库实现,合理区分文法导入机制与外部符号机制的实现区别。

去除以词法或语法结构为单位导入其它文法定义文件的支持

保留将其他语言导入为一个外部符号应用在当前语言的文法中的外部符号机制

恢复grammer的文法定义,令它的全部构成均定义在同一个文件

对应检查grammar加载器中硬编码的用于解析grammer自身的文法定义需要与grammer的设计保持一致。


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Remove grammar definition file import mechanism Remove grammar import mechanism, preserve external symbol mechanism Dec 5, 2025
Copilot AI requested a review from godgnidoc December 5, 2025 02:37
@godgnidoc godgnidoc requested a review from Copilot December 5, 2025 03:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR successfully separates the grammar import mechanism from the external symbol mechanism, removing the former while preserving the latter. The changes enable embedding other languages as external symbols in grammars without the complexity of importing individual lexical/syntactical units.

Key changes:

  • Removed using statements and related term.using/ntrm.using rules from grammar definition
  • Preserved ntrm.external for loading external grammars as symbols
  • Added ExternalLoader callback type to support external symbol loading via syntax.Import()

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
grammar/grammar.grammar Removed USING terminal and using/usings rules; simplified term to single pattern; kept ntrm.external for external symbols
include/aliox/grammar.h Added ExternalLoader callback type and overloaded Compile() method to accept external loader
src/aliox/grammar.cpp Implemented external symbol loading logic; simplified term/ntrm processing by removing import-related branches
generated/include/grammar/syntax.h Updated hardcoded syntax to match simplified grammar; removed Using struct and related code; adjusted symbol/formula IDs
include/alioth/println_compat.h Added compatibility shim for fmt::println on fmt < 10.0.0
src/alioth/syntax.cpp, src/alioth/parser.cpp, src/aliox/template.cpp, src/alioth-cli/skeleton.cpp, src/alioth-cli/parse.cpp Added println_compat.h include for fmt compatibility
.gitignore Added _codeql_build_dir/ to ignored paths

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +12 to +21
inline void println(FILE* f, const S& format, Args&&... args) {
print(f, fmt::runtime(format), std::forward<Args>(args)...);
std::fputc('\n', f);
}

template <typename S, typename... Args>
inline void println(const S& format, Args&&... args) {
print(fmt::runtime(format), std::forward<Args>(args)...);
std::putchar('\n');
}
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compatibility implementation unconditionally wraps format strings with fmt::runtime(), which bypasses compile-time format string validation even for string literals. This should only be used for runtime format strings. Consider removing fmt::runtime() wrapper to preserve compile-time checking:

template <typename S, typename... Args>
inline void println(FILE* f, const S& format, Args&&... args) {
  print(f, format, std::forward<Args>(args)...);
  std::fputc('\n', f);
}

template <typename S, typename... Args>
inline void println(const S& format, Args&&... args) {
  print(format, std::forward<Args>(args)...);
  std::putchar('\n');
}

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

2 participants