Skip to content

Commit

Permalink
Merge pull request #4158 from sorig/meta_ruby_method_call_fix
Browse files Browse the repository at this point in the history
Switch translation of ruby function calls to allow nested calls
  • Loading branch information
karlnapf committed Feb 7, 2018
2 parents df63984 + 3e3b166 commit abb0e4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
20 changes: 10 additions & 10 deletions examples/meta/generator/targets/ruby.json
Expand Up @@ -3,11 +3,11 @@
"Statement": "$statement\n",
"Comment": "#$comment\n",
"Init": {
"Construct": "$name = Shogun::$typeName.new $arguments$kwargs",
"Construct": "$name = Shogun::$typeName.new($arguments)$kwargs",
"Copy": "$name = $expr$kwargs",
"KeywordArguments": {
"List": "\n$elements",
"Element": "$name.put \"$keyword\", $expr",
"Element": "$name.put(\"$keyword\", $expr)",
"Separator": "\n",
"InitialSeperatorWhenArgs>0": false
},
Expand Down Expand Up @@ -46,28 +46,28 @@
"IntLiteral": "$number",
"RealLiteral": "$number",
"FloatLiteral": "$number",
"MethodCall": "$object.$method $arguments",
"StaticCall": "Shogun::$typeName.$method $arguments",
"GlobalCall": "Shogun::$method $arguments",
"MethodCall": "$object.$method($arguments)",
"StaticCall": "Shogun::$typeName.$method($arguments)",
"GlobalCall": "Shogun::$method($arguments)",
"Identifier": "$identifier",
"Enum":"Shogun::$value"
},
"Element": {
"Access": {
"Vector": "$identifier[$indices]",
"Matrix": "$identifier[$indices]",
"BoolVector": "$identifier.get_element $indices",
"BoolMatrix": "$identifier.get_element $indices"
"BoolVector": "$identifier.get_element($indices)",
"BoolMatrix": "$identifier.get_element($indices)"
},
"Assign": {
"Vector": "$identifier[$indices] = $expr",
"Matrix": "$identifier[$indices] = $expr",
"BoolVector": "$identifier.set_element $expr, $indices",
"BoolMatrix": "$identifier.set_element $expr, $indices"
"BoolVector": "$identifier.set_element($expr, $indices)",
"BoolMatrix": "$identifier.set_element($expr, $indices)"
},
"ZeroIndexed": true
},
"Print": "puts $expr",
"Print": "puts($expr)",
"OutputDirectoryName": "ruby",
"FileExtension": ".rb"
}
5 changes: 1 addition & 4 deletions examples/meta/src/meta_api/kwargs.sg
Expand Up @@ -22,14 +22,11 @@
# This also fails (keywords not allowed outside initialisation variables)
#kernel_factory("GaussianKernel", a=glob_fun(ordinary_argument))

# doesnt work in ruby (TODO, don't allow in meta grammar)
# KernelMachine svm2 = kernel_machine("LibSVM", kernel=kernel("GaussianKernel"))



# Real example
# ------------

Kernel k = kernel("GaussianKernel", log_width=2.0)
KernelMachine svm = kernel_machine("LibSVM", C1=1.1, kernel=k)

KernelMachine svm2 = kernel_machine("LibSVM", kernel=kernel("GaussianKernel"))

0 comments on commit abb0e4a

Please sign in to comment.