Giter Site home page Giter Site logo

Comments (3)

amaanq avatar amaanq commented on August 29, 2024

Please, post code and the parse output of tree-sitter parse <foo.sh>, a screenshot is not helpful (clone the repo and then run tree-sitter parse)

from tree-sitter-bash.

pseudoClone avatar pseudoClone commented on August 29, 2024

This is the bash program:


# made by @felioakz + google + chatGPT :)

# to execute: $ ./pomodoro.sh [argument] (argument: an interger representing minutes)

# Check if a duration argument was provided
clear -x
echo -e "\n"
echo "██████╗  ██████╗ ███╗   ███╗ ██████╗ 
██╔══██╗██╔═══██╗████╗ ████║██╔═══██╗
██████╔╝██║   ██║██╔████╔██║██║   ██║
██╔═══╝ ██║   ██║██║╚██╔╝██║██║   ██║
██║     ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝
╚═╝      ╚═════╝ ╚═╝     ╚═╝ ╚═════╝ 
"
echo -e "\n"
if [ -z "$1" ]; then
	echo "Error: Please provide the duration of the Pomodoro in minutes as an argument."
	exit 1

# validation with regex to check input as interger
else
	# Check if the input is an integer
	if [[ $1 =~ ^[0-9]+$ ]]; then
		duration=$1
	else
		echo "Error: Please provide a valid integer as the duration of the Pomodoro in minutes."
		exit 1
	fi
fi

stty -echo

# Start the timer
echo "POMODORO TIMER started for $duration minutes ( Local time: $(date +'%r'))"

# terminal width to variable
width=$(tput cols)

# Use a loop to update the status bar every second
for ((i=1; i<=duration*60; i++)); do
	# Calculate the percentage of the duration that has passed
	percentage=$((i*100/(duration*60)))

	# Print the percentage
	printf "\r %d%%" $percentage

	for ((j=1; j<=percentage && j<= width; j+=3)); do
		printf "|"
	done
	# Sleep for one second
	sleep 1
done
if [[ "$(uname -s)" == "Linux" ]]; then

	notify-send "Time's up! POMODORO TIMER Completed!"
	paplay mp3x.mp3
else
	# Assuming that the system is BSD and libnotify exists
	# Todo: Support for MAC Users
	
	sendmsg "Pomo" "Time's up! POMODORO TIMER Completed!"
	if [[ $(psgrep -x sndio) == 1 ]]; then
		sndio -d
	fi
	while [[ $(sndio play mp3x.mp3) ]]; do
		sleep	
	done
fi

# paplay default system alert sound
# paplay /usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga

reset

And this is the parser output:

(program [0, 0] - [75, 0]
  (comment [0, 0] - [0, 9])
  (comment [2, 0] - [2, 41])
  (comment [4, 0] - [4, 85])
  (comment [6, 0] - [6, 43])
  (command [7, 0] - [7, 8]
    name: (command_name [7, 0] - [7, 5]
      (word [7, 0] - [7, 5]))
    argument: (word [7, 6] - [7, 8]))
  (command [8, 0] - [8, 12]
    name: (command_name [8, 0] - [8, 4]
      (word [8, 0] - [8, 4]))
    argument: (word [8, 5] - [8, 7])
    argument: (string [8, 8] - [8, 12]
      (string_content [8, 9] - [8, 11])))
  (command [9, 0] - [15, 1]
    name: (command_name [9, 0] - [9, 4]
      (word [9, 0] - [9, 4]))
    argument: (string [9, 5] - [15, 1]
      (string_content [9, 6] - [9, 101])
      (string_content [10, 0] - [10, 109])
      (string_content [11, 0] - [11, 99])
      (string_content [12, 0] - [12, 97])
      (string_content [13, 0] - [13, 97])
      (string_content [14, 0] - [14, 83])))
  (command [16, 0] - [16, 12]
    name: (command_name [16, 0] - [16, 4]
      (word [16, 0] - [16, 4]))
    argument: (word [16, 5] - [16, 7])
    argument: (string [16, 8] - [16, 12]
      (string_content [16, 9] - [16, 11])))
  (if_statement [17, 0] - [30, 2]
    condition: (test_command [17, 3] - [17, 14]
      (unary_expression [17, 5] - [17, 12]
        operator: (test_operator [17, 5] - [17, 7])
        (string [17, 8] - [17, 12]
          (simple_expansion [17, 9] - [17, 11]
            (variable_name [17, 10] - [17, 11])))))
    (command [18, 1] - [18, 85]
      name: (command_name [18, 1] - [18, 5]
        (word [18, 1] - [18, 5]))
      argument: (string [18, 6] - [18, 85]
        (string_content [18, 7] - [18, 84])))
    (command [19, 1] - [19, 7]
      name: (command_name [19, 1] - [19, 5]
        (word [19, 1] - [19, 5]))
      argument: (number [19, 6] - [19, 7]))
    (comment [21, 0] - [21, 50])
    (else_clause [22, 0] - [30, 0]
      (comment [23, 1] - [23, 35])
      (if_statement [24, 1] - [29, 3]
        condition: (test_command [24, 4] - [24, 24]
          (binary_expression [24, 7] - [24, 21]
            left: (simple_expansion [24, 7] - [24, 9]
              (variable_name [24, 8] - [24, 9]))
            right: (regex [24, 13] - [24, 21])))
        (variable_assignment [25, 2] - [25, 13]
          name: (variable_name [25, 2] - [25, 10])
          value: (simple_expansion [25, 11] - [25, 13]
            (variable_name [25, 12] - [25, 13])))
        (else_clause [26, 1] - [29, 0]
          (command [27, 2] - [27, 90]
            name: (command_name [27, 2] - [27, 6]
              (word [27, 2] - [27, 6]))
            argument: (string [27, 7] - [27, 90]
              (string_content [27, 8] - [27, 89])))
          (command [28, 2] - [28, 8]
            name: (command_name [28, 2] - [28, 6]
              (word [28, 2] - [28, 6]))
            argument: (number [28, 7] - [28, 8]))))))
  (command [32, 0] - [32, 10]
    name: (command_name [32, 0] - [32, 4]
      (word [32, 0] - [32, 4]))
    argument: (word [32, 5] - [32, 10]))
  (comment [34, 0] - [34, 17])
  (command [35, 0] - [35, 80]
    name: (command_name [35, 0] - [35, 4]
      (word [35, 0] - [35, 4]))
    argument: (string [35, 5] - [35, 80]
      (string_content [35, 6] - [35, 33])
      (simple_expansion [35, 33] - [35, 42]
        (variable_name [35, 34] - [35, 42]))
      (string_content [35, 42] - [35, 65])
      (command_substitution [35, 65] - [35, 78]
        (command [35, 67] - [35, 77]
          name: (command_name [35, 67] - [35, 71]
            (word [35, 67] - [35, 71]))
          argument: (concatenation [35, 72] - [35, 77]
            (word [35, 72] - [35, 73])
            (raw_string [35, 73] - [35, 77]))))
      (string_content [35, 78] - [35, 79])))
  (comment [37, 0] - [37, 28])
  (variable_assignment [38, 0] - [38, 18]
    name: (variable_name [38, 0] - [38, 5])
    value: (command_substitution [38, 6] - [38, 18]
      (command [38, 8] - [38, 17]
        name: (command_name [38, 8] - [38, 12]
          (word [38, 8] - [38, 12]))
        argument: (word [38, 13] - [38, 17]))))
  (comment [40, 0] - [40, 50])
  (c_style_for_statement [41, 0] - [53, 4]
    initializer: (variable_assignment [41, 6] - [41, 9]
      name: (variable_name [41, 6] - [41, 7])
      value: (number [41, 8] - [41, 9]))
    condition: (binary_expression [41, 11] - [41, 25]
      left: (word [41, 11] - [41, 12])
      right: (binary_expression [41, 14] - [41, 25]
        left: (word [41, 14] - [41, 22])
        right: (number [41, 23] - [41, 25])))
    update: (postfix_expression [41, 27] - [41, 30]
      (word [41, 27] - [41, 28]))
    body: (do_group [41, 34] - [53, 4]
      (comment [42, 1] - [42, 59])
      (variable_assignment [43, 1] - [43, 36]
        name: (variable_name [43, 1] - [43, 11])
        value: (arithmetic_expansion [43, 12] - [43, 36]
          (binary_expression [43, 15] - [43, 34]
            left: (binary_expression [43, 15] - [43, 20]
              left: (variable_name [43, 15] - [43, 16])
              right: (number [43, 17] - [43, 20]))
            right: (parenthesized_expression [43, 21] - [43, 34]
              (binary_expression [43, 22] - [43, 33]
                left: (variable_name [43, 22] - [43, 30])
                right: (number [43, 31] - [43, 33]))))))
      (comment [45, 1] - [45, 23])
      (command [46, 1] - [46, 29]
        name: (command_name [46, 1] - [46, 7]
          (word [46, 1] - [46, 7]))
        argument: (string [46, 8] - [46, 17]
          (string_content [46, 9] - [46, 16]))
        argument: (simple_expansion [46, 18] - [46, 29]
          (variable_name [46, 19] - [46, 29])))
      (c_style_for_statement [48, 1] - [50, 5]
        initializer: (variable_assignment [48, 7] - [48, 10]
          name: (variable_name [48, 7] - [48, 8])
          value: (number [48, 9] - [48, 10]))
        condition: (binary_expression [48, 12] - [48, 38]
          left: (binary_expression [48, 12] - [48, 25]
            left: (word [48, 12] - [48, 13])
            right: (word [48, 15] - [48, 25]))
          right: (binary_expression [48, 29] - [48, 38]
            left: (word [48, 29] - [48, 30])
            right: (word [48, 33] - [48, 38])))
        update: (binary_expression [48, 40] - [48, 44]
          left: (word [48, 40] - [48, 41])
          right: (number [48, 43] - [48, 44]))
        body: (do_group [48, 48] - [50, 5]
          (command [49, 2] - [49, 12]
            name: (command_name [49, 2] - [49, 8]
              (word [49, 2] - [49, 8]))
            argument: (string [49, 9] - [49, 12]
              (string_content [49, 10] - [49, 11])))))
      (comment [51, 1] - [51, 23])
      (command [52, 1] - [52, 8]
        name: (command_name [52, 1] - [52, 6]
          (word [52, 1] - [52, 6]))
        argument: (number [52, 7] - [52, 8]))))
  (if_statement [54, 0] - [69, 2]
    condition: (test_command [54, 3] - [54, 33]
      (binary_expression [54, 6] - [54, 30]
        left: (string [54, 6] - [54, 19]
          (command_substitution [54, 7] - [54, 18]
            (command [54, 9] - [54, 17]
              name: (command_name [54, 9] - [54, 14]
                (word [54, 9] - [54, 14]))
              argument: (word [54, 15] - [54, 17]))))
        right: (string [54, 23] - [54, 30]
          (string_content [54, 24] - [54, 29]))))
    (command [56, 1] - [56, 51]
      name: (command_name [56, 1] - [56, 12]
        (word [56, 1] - [56, 12]))
      argument: (string [56, 13] - [56, 51]
        (string_content [56, 14] - [56, 50])))
    (command [57, 1] - [57, 16]
      name: (command_name [57, 1] - [57, 7]
        (word [57, 1] - [57, 7]))
      argument: (word [57, 8] - [57, 16]))
    (else_clause [58, 0] - [69, 0]
      (comment [59, 1] - [59, 55])
      (comment [60, 1] - [60, 30])
      (command [62, 1] - [62, 54]
        name: (command_name [62, 1] - [62, 8]
          (word [62, 1] - [62, 8]))
        argument: (string [62, 9] - [62, 15]
          (string_content [62, 10] - [62, 14]))
        argument: (string [62, 16] - [62, 54]
          (string_content [62, 17] - [62, 53])))
      (if_statement [63, 1] - [65, 3]
        condition: (test_command [63, 4] - [63, 33]
          (binary_expression [63, 7] - [63, 30]
            left: (command_substitution [63, 7] - [63, 25]
              (command [63, 9] - [63, 24]
                name: (command_name [63, 9] - [63, 15]
                  (word [63, 9] - [63, 15]))
                argument: (word [63, 16] - [63, 18])
                argument: (word [63, 19] - [63, 24])))
            right: (number [63, 29] - [63, 30])))
        (command [64, 2] - [64, 10]
          name: (command_name [64, 2] - [64, 7]
            (word [64, 2] - [64, 7]))
          argument: (word [64, 8] - [64, 10])))
      (while_statement [66, 1] - [68, 5]
        condition: (test_command [66, 7] - [66, 35]
          (command_substitution [66, 10] - [66, 32]
            (command [66, 12] - [66, 31]
              name: (command_name [66, 12] - [66, 17]
                (word [66, 12] - [66, 17]))
              argument: (word [66, 18] - [66, 22])
              argument: (word [66, 23] - [66, 31]))))
        body: (do_group [66, 37] - [68, 5]
          (command [67, 2] - [67, 7]
            name: (command_name [67, 2] - [67, 7]
              (word [67, 2] - [67, 7])))))))
  (comment [71, 0] - [71, 35])
  (comment [72, 0] - [72, 69])
  (command [74, 0] - [74, 5]
    name: (command_name [74, 0] - [74, 5]
      (word [74, 0] - [74, 5]))))

from tree-sitter-bash.

amaanq avatar amaanq commented on August 29, 2024

Yeah it parses fine so not a tree-sitter-bash bug, you probably need to update neovim/nvim-treesitter

from tree-sitter-bash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.