<div dir="ltr"><div><div>Hi Pierre-Andre,<br><br></div>for now I just change the while loop to look like this:<br>    while (getLexer().getKind() == AsmToken::Identifier || getLexer().getKind() == AsmToken::Integer)<br></div>and at the moment it seems like it is working, at least now! ;-)<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 28, 2015 at 4:58 PM, Pierre-Andre Saulais <span dir="ltr"><<a href="mailto:pierre-andre@codeplay.com" target="_blank">pierre-andre@codeplay.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Ah I see, I didn't think about spaces being ignored :)<br>
    <br>
    I just checked and MCAsmLexer has a setSkipSpace function that could
    be used to not ignore whitespace when parsing. I haven't tried it
    out though.<br>
    <br>
    Cheers,<br>
    Pierre-Andre<div><div class="h5"><br>
    <br>
    <div>On 28/09/15 14:41, Sky Flyer wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div>Hi Pierre-Andre<br>
          <br>
          Thanks for your prompt reply.<br>
          What I mean, is located at line 4192 <a>(</a><a href="http://code.woboq.org/llvm/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp.html#4192" target="_blank">http://code.woboq.org/llvm/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp.html#4192</a>).<br>
          It, first, has to parse the instruction, and based on the
          number of operands it uses a pattern in MatchAndEmit.<br>
          My problem is, what would be a suitable substitute if operands
          in the assembly code are not comma-separated, instead
          space-separated. (as you know, space is automatically removed
          so I cannot simply switch AsmToken::Comma to AsmToken::Space.)<br>
          <br>
        </div>
        Thanks a lot. :-)<br>
        <div><br>
          <br>
          <br>
          <div class="gmail_extra"><br>
            <div class="gmail_quote">On Mon, Sep 28, 2015 at 3:32 PM,
              Pierre-Andre Saulais <span dir="ltr"><<a href="mailto:pierre-andre@codeplay.com" target="_blank"></a><a href="mailto:pierre-andre@codeplay.com" target="_blank">pierre-andre@codeplay.com</a>></span>
              wrote:<br>
              <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div bgcolor="#FFFFFF" text="#000000"> Hi ES,<br>
                  <br>
                  From what I understand instruction parsing is divided
                  into two parts:<br>
                  <br>
                  - Parsing an operand list
                  (XXXAsmParser::ParseInstruction)<br>
                  - Turning the operand list into an actual instruction
                  (XXXAsmParser::MatchAndEmitInstruction)<br>
                  <br>
                  The second part does the validation (e.g. how many
                  operands, what kind, etc) while the first part only
                  does the parsing. That's why I think in the first part
                  you have to handle all possible operand combinations
                  (i.e. parse the first operand, and keep parsing
                  operands as long as you see spaces). LLVM will reject
                  instructions with too many operands (as defined in the
                  .td files).<br>
                  <br>
                  Is this something that would work with your assembly
                  syntax?<br>
                  <br>
                  Cheers,<br>
                  Pierre-Andre
                  <div>
                    <div><br>
                      <br>
                      <div>On 28/09/15 14:21, Sky Flyer via llvm-dev
                        wrote:<br>
                      </div>
                    </div>
                  </div>
                  <blockquote type="cite">
                    <div>
                      <div>
                        <div dir="ltr">
                          <div>practically I cannot use a function namly
                            <b>getMnemonicAcceptInfo</b> (mnemonic as
                            input, and number of possible outputs as
                            output), because there are mnemonics that
                            accepts different number of operands! :-/<br>
                            <br>
                          </div>
                          Any help is highly appreciated.<br>
                        </div>
                        <div class="gmail_extra"><br>
                          <div class="gmail_quote">On Mon, Sep 28, 2015
                            at 10:53 AM, Sky Flyer <span dir="ltr"><<a href="mailto:skylake007@googlemail.com" target="_blank"></a><a href="mailto:skylake007@googlemail.com" target="_blank">skylake007@googlemail.com</a>></span>
                            wrote:<br>
                            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                              <div dir="ltr">Hi all,<br>
                                <br>
                                in most of the architectures, assembly
                                operands are comma-separated.<br>
                                I would like to parse an assembly code
                                that is space-separated and I am having
                                a bit of problem.<br>
                                In <b>ParseInstruction</b> function, I
                                don't know what is the easiest way to
                                figure out how many operands a mnemonic
                                expected to have.<br>
                                In comma-separated assembly code, it
                                just consuming commas (while
                                (getLexer().is(AsmToken::Comma))) and
                                adds operands, but it's not the case for
                                space...<br>
                                <br>
                                I have a dirty hack, that I manually
                                provide such information (number of
                                operands) in a function called for
                                example getMnemonicAcceptInfo and with a
                                for loop I parse the operand!!<br>
                                <br>
                                What would you suggest for parsing
                                space-separated assembly codes when it
                                comes to figuring out if a mnemonic has
                                two operands or one?<br>
                                <br>
                                Cheers,<br>
                                ES</div>
                            </blockquote>
                          </div>
                          <br>
                        </div>
                        <br>
                        <fieldset></fieldset>
                        <br>
                      </div>
                    </div>
                    <pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
                  </blockquote>
                  <br>
                </div>
              </blockquote>
            </div>
            <br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br></div>