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

Some types of syntaxes are not recognized #4

Open
kasperk81 opened this issue Jun 26, 2021 · 3 comments
Open

Some types of syntaxes are not recognized #4

kasperk81 opened this issue Jun 26, 2021 · 3 comments

Comments

@kasperk81
Copy link

setup:

$ cat test2.S
str x29, [x0, #(0xb0 + 0x0f0)]

# test with gcc
$ aarch64-linux-gnu-gcc -S -o - test2.S
# 1 "test2.S"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/aarch64-linux-gnu/include/stdc-predef.h" 1 3
# 32 "<command-line>" 2
# 1 "test2.S"
str x29, [x0, #(0xb0 + 0x0f0)]

first error:

$ aarch64-linux-gnu-gcc -S -o - test2.S | python3 arm2riscv.py
Traceback (most recent call last):
  File "arm2riscv.py", line 59, in <module>
    tree = l.parse(line)
  File "/usr/local/lib/python3.6/dist-packages/lark/lark.py", line 561, in parse
    return self.parser.parse(text, start=start, on_error=on_error)
  File "/usr/local/lib/python3.6/dist-packages/lark/parser_frontends.py", line 107, in parse
    return self.parser.parse(stream, start, **kw)
  File "/usr/local/lib/python3.6/dist-packages/lark/parsers/earley.py", line 298, in parse
    to_scan = self._parse(lexer, columns, to_scan, start_symbol)
  File "/usr/local/lib/python3.6/dist-packages/lark/parsers/xearley.py", line 144, in _parse
    to_scan = scan(i, to_scan)
  File "/usr/local/lib/python3.6/dist-packages/lark/parsers/xearley.py", line 120, in scan
    considered_rules=considered_rules
lark.exceptions.UnexpectedCharacters: No terminal matches '1' in the current parser context, at line 1 col 3

# 1 "test2.S"
  ^
Expected one of: 
        * CNAME

ok so i will omit the ^# lines...

$ aarch64-linux-gnu-gcc -S -o - test2.S | grep -v '^#' | python3 arm2riscv.py 
Traceback (most recent call last):
  File "arm2riscv.py", line 59, in <module>
    tree = l.parse(line)
  File "/usr/local/lib/python3.6/dist-packages/lark/lark.py", line 561, in parse
    return self.parser.parse(text, start=start, on_error=on_error)
  File "/usr/local/lib/python3.6/dist-packages/lark/parser_frontends.py", line 107, in parse
    return self.parser.parse(stream, start, **kw)
  File "/usr/local/lib/python3.6/dist-packages/lark/parsers/earley.py", line 298, in parse
    to_scan = self._parse(lexer, columns, to_scan, start_symbol)
  File "/usr/local/lib/python3.6/dist-packages/lark/parsers/xearley.py", line 144, in _parse
    to_scan = scan(i, to_scan)
  File "/usr/local/lib/python3.6/dist-packages/lark/parsers/xearley.py", line 120, in scan
    considered_rules=considered_rules
lark.exceptions.UnexpectedCharacters: No terminal matches '(' in the current parser context, at line 1 col 16

str x29, [x0, #(0xb0 + 0x0f0)]
               ^
Expected one of: 
        * NUMBER
        * SIGNED_NUMBER
        * __ANON_1
@schorrm
Copy link
Owner

schorrm commented Jun 27, 2021

I am pleasantly surprised someone actually uses this enough to report an issue

@schorrm
Copy link
Owner

schorrm commented Jun 27, 2021

Where did that syntax come from?

@kasperk81
Copy link
Author

I was trying to convert an aarch64 assembly file to riscv64: https://github.com/libunwind/libunwind/blob/ffd0c05e8fabef6e2f41569c8d5680eaf5168749/src/aarch64/getcontext.S#L42

asm2riscv is a unique tool, when we need some quick reference to what the transpired form would look like, this repo tops the google search result. understandably, the output is not necessarily for production use, but sometimes this sort of tool helps analyzing code. 🙂

ps I was hoping to find its web-based version like https://godbolt.org/ and https://sharplab.io/ and in future more source/target options

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

No branches or pull requests

2 participants