logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

strace.lua (1113B)


  1. -- Copyright 2017-2024 Marc André Tanner. See LICENSE.
  2. -- strace(1) output lexer
  3. local lexer = lexer
  4. local S, B = lpeg.S, lpeg.B
  5. local lex = lexer.new(..., {lex_by_line = true})
  6. -- Syscall
  7. lex:add_rule('syscall', lex:tag(lexer.FUNCTION, lexer.starts_line(lexer.word)))
  8. -- Upper case constants
  9. lex:add_rule('constant',
  10. lex:tag(lexer.CONSTANT, (lexer.upper + '_') * (lexer.upper + lexer.digit + '_')^0))
  11. -- Single and double quoted strings
  12. local sq_str = lexer.range("'", true)
  13. local dq_str = lexer.range('"', true)
  14. lex:add_rule('string', lex:tag(lexer.STRING, sq_str + dq_str))
  15. -- Comments and text in parentheses at the line end
  16. local comment = lexer.range('/*', '*/')
  17. local description = lexer.range('(', ')') * lexer.newline
  18. lex:add_rule('comment', lex:tag(lexer.COMMENT, comment + description))
  19. lex:add_rule('result', lex:tag(lexer.TYPE, B(' = ') * lexer.integer))
  20. lex:add_rule('identifier', lex:tag(lexer.IDENTIFIER, lexer.word))
  21. lex:add_rule('number', lex:tag(lexer.NUMBER, lexer.float + lexer.integer))
  22. lex:add_rule('operator', lex:tag(lexer.OPERATOR, S('+-/*%<>~!=^&|?~:;,.()[]{}')))
  23. return lex