Permalink
Browse files

[VRG]

- cleaned up the operator definition syntax even further.
  now we can write
    prefix:<~>  not
    prefix:<\>  line
    prefix:<#>  plane
    infix_prefix:<~> not_ &
  instead of
    prefix:<~>  "not "
    prefix:<\>  "line "
    prefix:<#>  "plane "
    infix_prefix:<~> "not_"
  however, the more general string syntax is still
  supported. :)

git-svn-id: http://svn.berlios.de/svnroot/repos/unisimu/VRG@859 625e195c-0704-0410-94f2-f261ee9f2fe7
  • Loading branch information...
agent
agent committed Nov 12, 2006
1 parent 2cb0549 commit b9647f6ae18dc6eb77bc17fc4a8e80e82cb838c0
Showing with 29 additions and 22 deletions.
  1. +11 −8 grammar/xclips.grammar
  2. +11 −11 knowledge/vrg-sugar.xclp
  3. +7 −3 lib/XClips/Compiler.pm
View
@@ -93,32 +93,35 @@ directive : 'module' <commit> identifier '.' ws
{ $item{predicate} }
- | 'prefix:<' <commit> <skip:''> pattern '>' <skip:'\s*'> string /\.?/ ws
+ | 'prefix:<' <commit> <skip:''> pattern '>' <skip:'\s*'> target /\.?/ ws
- { $::prefix{$item{pattern}} = eval $item{string};
+ { $::prefix{$item{pattern}} = eval $item{target};
@::prefix = sort { -($a cmp $b) } keys %::prefix; '' }
- | 'infix:<' <commit> <skip:''> pattern '>' <skip:'\s*'> string /\.?/ ws
+ | 'infix:<' <commit> <skip:''> pattern '>' <skip:'\s*'> target /\.?/ ws
- { $::infix{$item{pattern}} = eval $item{string};
+ { $::infix{$item{pattern}} = eval $item{target};
@::infix = sort { -($a cmp $b) } keys %::infix; '' }
- | 'infix_prefix:<' <commit> <skip:''> pattern '>' <skip:'\s*'> string /\.?/ ws
+ | 'infix_prefix:<' <commit> <skip:''> pattern '>' <skip:'\s*'> target /\.?/ ws
- { $::infix_prefix{$item{pattern}} = eval $item{string};
+ { $::infix_prefix{$item{pattern}} = eval $item{target};
@::infix_prefix = sort { -($a cmp $b) } keys %::infix_prefix; '' }
| 'infix_circumfix:<' <commit> <skip:''> circum_pattern '>'
- <skip:'\s*'> string /\.?/ ws
+ <skip:'\s*'> target /\.?/ ws
{ my $pattern = $item{circum_pattern};
#warn "~~~ @$pattern\n";
- $::infix_circumfix{$pattern->[0]} = eval $item{string};
+ $::infix_circumfix{$pattern->[0]} = eval $item{target};
$::infix_circum_close{$pattern->[0]} = $pattern->[1];
@::infix_circumfix = sort { -($a cmp $b) } keys %::infix_circumfix; '' }
| <error?> <reject>
+target : identifier /\&?/ { $item[2] ? "'$item[1]'" : "'$item[1] '" }
+ | string
+
pattern : /\S+(?=>)/
circum_pattern : /(\S+) (\S+)(?=>)/ <commit> { [$1, $2] }
View
@@ -1,15 +1,15 @@
/* syntax sugar definitions for the VRG knowledge base */
-prefix:<~> "not "
-prefix:<\> "line "
-prefix:<#> "plane "
+prefix:<~> not
+prefix:<\> line
+prefix:<#> plane
-infix:<//> "parallel "
-infix:<T> "orthogonal "
-infix:<X> "cross "
-infix:<on> "on "
+infix:<//> parallel
+infix:<T> orthogonal
+infix:<X> cross
+infix:<on> on
-infix_prefix:<*> "goal "
-infix_prefix:<~> "not_"
-infix_circumfix:<[ ]> "space-relation "
-infix_circumfix:<< >> "vector-relation "
+infix_prefix:<*> goal
+infix_prefix:<~> not_ &
+infix_circumfix:<[ ]> space-relation
+infix_circumfix:<< >> vector-relation
View
@@ -24,9 +24,13 @@ our (%prefix, %infix, %infix_prefix, %infix_circumfix, %infix_circum_close);
our (@prefix, @infix, @infix_prefix, @infix_circumfix);
%infix = (
- '\=' => "test (neq ",
- '==' => "test (eq ",
- ':=' => "bind ",
+ '\=' => 'test (neq ',
+ '==' => 'test (eq ',
+ ':=' => 'bind ',
+ '>=' => '>= ',
+ '>' => '> ',
+ '<=' => '<= ',
+ '<' => "< ",
);
sub match_prefix {

0 comments on commit b9647f6

Please sign in to comment.