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

Support julia #175

Closed
jolars opened this issue Jan 10, 2025 · 4 comments
Closed

Support julia #175

jolars opened this issue Jan 10, 2025 · 4 comments
Labels
enhancement New feature or request

Comments

@jolars
Copy link

jolars commented Jan 10, 2025

It would be nice to support julia. We could probably borrow a lot from for instance the R and python parsers.

@Wansmer
Copy link
Owner

Wansmer commented Jan 13, 2025

In order to add a new language, I need sample code with oneline/multiline nodes for that language (example: https://github.com/Wansmer/treesj/tree/main/tests/sample).

@Wansmer Wansmer added the enhancement New feature or request label Jan 13, 2025
@jolars
Copy link
Author

jolars commented Jan 17, 2025

I hope this is something along the lines of what you wanted. I am not 100% sure if I got it right, for instance I just put preset default everywhere, but I don't really know what that does :). I also wasn't sure if the nested array needed special handling or not

# RESULT OF JOIN (node "argument_list", preset default)
filled_dict = Dict("one" => 1, "two" => 2, "three" => 3)
# RESULT OF SPLIT (node "argument_list", preset default)
filled_dict = Dict(
  "one" => 1,
  "two" => 2,
  "three" => 3,
)

# RESULT OF JOIN (node "vector_expression", preset default)
other_arr = [4, 5, 6]
# RESULT OF SPLIT (node "vector_expression", preset default)
other_arr = [
  4,
  5,
  6,
]

# RESULT OF JOIN (node "matrix_expression", preset default)
other_arr = [1 2 3; 4 5 6]
# RESULT OF SPLIT (node "matrix_expression", preset default)
other_arr = [
  1 2 3
  4 5 6
]

# RESULT OF JOIN (node "vector_expression", preset default)
other_arr = [[1 2 3], [4 5 6]]
# RESULT OF SPLIT (node "vector_expression", preset default)
other_arr = [
  [1 2 3],
  [4 5 6],
]

# RESULT OF JOIN (node "vector_expression", preset default)
multi_arr = [[1, 2], [3, 4], [5, 6]]
# RESULT OF SPLIT (node "vector_expression", preset default)
multi_arr = [
  [1, 2],
  [3, 4],
  [5, 6],
]

# RESULT OF JOIN (node "tuple_expression", preset default)
tup = (1, 2, 3)
# RESULT OF SPLIT (node "tuple_expression", preset default)
tup = (
  1,
  2,
  3,
)

# RESULT OF JOIN (node "argument_list" and "function_definition", preset default)
function create_adder(x, b)
  adder(y) = x + y
  return adder
end

# RESULT OF SPLIT (node "argument_list" and "function_definition", preset default)
function create_adder(
  x,
  b,
)
  adder(y) = x + y
  return adder
end

# RESULT OF JOIN (node "comprehension_expression", preset default)
comp_arr = [i^2 for i in 1:5]
# RESULT OF SPLIT (node "comprehension_expression", preset default)
comp_arr = [
  i^2
  for i in 1:5
]

# RESULT OF JOIN (node "call_expression", preset default)
result = sum([1, 2, 3])
# RESULT OF SPLIT (node "call_expression", preset default)
result = sum(
  [1, 2, 3]
)

# RESULT OF JOIN (node "using_statement", preset default)
using Statistics, Lasso, ProjectRoot
# RESULT OF SPLIT (node "using_statement", preset default)
using Statistics,
  Lasso,
  ProjectRoot

# RESULT OF JOIN (node "selected_import" and "using_statement", preset default)
using Statistics: mean, median, std
# RESULT OF SPLIT (node "selected_import" and "using_statement", preset default)
using Statistics:
  mean,
  median,
  std

# RESULT OF JOIN (node "open_tuple" and "assignment", preset default)
t1, t2, t3 = (1, 2, 3)
# RESULT OF SPLIT (node "tuple_expression" and "assignment", preset default)
(
  t1,
  t2,
  t3,
) = (1, 2, 3)

@Wansmer
Copy link
Owner

Wansmer commented Jan 21, 2025

Done #178

@Wansmer Wansmer closed this as completed Jan 21, 2025
@jolars
Copy link
Author

jolars commented Jan 21, 2025

Great! Thanks a lot for the work on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants