← 输入框|github.com|刷新
Skip to content

Implement the sep keyword argument in print() #665

Closed

Description

@certik

Example:

print("a","b","c",sep=",")

This I think might be easy: simply extract/check it in ast->asr, and insert , instead of between the other arguments.

Activity

  1. redbopo commented on Jun 24, 2022

    @redbopo
    Contributor

    I think it's likely that handle_print() function will auto add sep=' ' in asr->llvm

    if (i < fmt.size()-1) fmt_str += " ";

    more, I debug with it (new to the parser with asdl format)

    Vec<ASR::expr_t*> args_expr = ASRUtils::call_arg2expr(al, args);

    Screenshot from 2022-06-25 01-22-57

    I think the args should be 4 instead of 3, though not have a good idea how to fix it yet.
    Maybe we need to implement it from start with asdl.

  2. faze-geek commented on Jun 25, 2022

    @faze-geek
    Contributor

    I guess this will also need modifications in python_ast_to_asr.cpp , as of now the separator is not recognised in the asr .

    ./src/bin/lpython try.py --show-asr --indent && ./a.out 
                   (Print () [
                      (StringConstant "a" 
                         (Character 1 1 () [])) 
                      (StringConstant "b" 
                         (Character 1 1 () [])) 
                      (StringConstant "c" 
                         (Character 1 1 () []))])] 
                   Source 
                   Public 
                   Implementation () .false. .false.), 
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions