]> git.mdlowis.com Git - archive/dlang.git/commitdiff
Disabled grouping operator and removed grave acceent from list literal syntax
authorMike D. Lowis <mike@mdlowis.com>
Thu, 1 Mar 2012 20:02:50 +0000 (15:02 -0500)
committerMike D. Lowis <mike@mdlowis.com>
Thu, 1 Mar 2012 20:02:50 +0000 (15:02 -0500)
example.dl
source/dllexer/dllexer.cpp
source/dlparser/dlparser.cpp
source/dlparser/dlparser.h

index 2a87765d102db5dc6d48b2b15e3a47b7365d4d39..27cc0a37291b157288eb49ab0edc4c9a41324bc0 100644 (file)
-#------------------------------------------------------------------------------
-# Macro Tests
-#------------------------------------------------------------------------------
-# Macro Definitions
-% if ( cond, branch1:Block ) {
-    exec_if( cond, branch1 )
-}
-
-% ifelse ( cond, branch1:Block, branch2:Block ) {
-    exec_if( cond, branch1, branch2 )
-}
-
-% foreach ( lst, fn:Block ) {
-    for_each(fn, lst)
-}
-
-# Macro Uses
-if (1 == 1)
-{
-    print("1 Hello, World!")
-}
-
-if (1 == 1)
-{
-
-}
-else
-{
-
-}
-
-if (1 == 0)
-{
-    print("Hello, World!")
-}
-
-ifelse (1 == 1)
-{
-    print("2 Hello, World!")
-}{
-    error("Incorrect branch was taken.")
-}
-
-ifelse (1 == 0)
-{
-    error("Incorrect branch was taken.")
-}{
-    print("3 Hello, World!")
-}
-
-#------------------------------------------------------------------------------
-# Collection Access and Iteration Tests
-#------------------------------------------------------------------------------
-# Accessing elements of lists, vectors, and strings
-lst1 = `(4,5,6)
-print(lst1[0], " Hello, World!")
-
-vec1 = [4,5,6]
-print(vec1[1], " Hello, World!")
-
-str1 = "456"
-print(str1[2], " Hello, World!")
-
-# Iterating over lists, vectors, and strings
-lst_foo = `(7,8,9,10)
-foreach lst_foo { |a|
-    print(a," Hello, World!")
-}
-
-vec_foo = [11,12,13,14,15]
-foreach vec_foo { |a,b|
-    print(b," Hello, World!")
-}
-
-str_foo = "6789"
-foreach str_foo { |a|
-    print(1,a," Hello, World!")
-}
-
-#------------------------------------------------------------------------------
-# Delayed Evaluation
-#------------------------------------------------------------------------------
-#% delay ( exp ) {
-#    make_promise({ exp })
-#}
-#
-#% force ( prom ) {
-#    force( prom )
-#}
-#
-#foo = delay nonexistent_var + 1
-#nonexistent_var = 19
-#assert( typeof(foo) == Block )
-#assert( typeof( force foo ) == Num )
-#print( force( foo ), " Hello, World!" )
-
-#------------------------------------------------------------------------------
-# Type Checking Tests
-#------------------------------------------------------------------------------
-assert( typeof( 1.1 ) == Num )
-assert( typeof( 'A' ) == Char )
-assert( typeof( `(1,2,3) ) == List )
-assert( typeof( [1,2,3] ) == Vector )
-assert( typeof( $Foo ) == Symbol )
-assert( typeof( {|a| a + 1} ) == Block )
-
+foo = ()
+foo = (1,2,3)
+foo = []
+foo = [1,2,3]
+foo = ""
+foo = "123"
+foo = 'a'
+foo = 1.0
+foo = $foo
+foo[0]
+
+foo = 1 + 1 * 1 - 1
index a2e4e3b9a6972d964e6fdd478bc24515031f7ab2..eb9cfa603f69d6ba755b3e950eaff042f683ce53 100644 (file)
@@ -4,7 +4,7 @@
 
 using namespace std;
 
-#define NUM_SINGLE_CHAR_MATCHES 14
+#define NUM_SINGLE_CHAR_MATCHES 13
 SingleCharMatch_T Single_Character_Matches[ NUM_SINGLE_CHAR_MATCHES ] = {
     { '[', LBRACK },
     { ']', RBRACK },
@@ -17,7 +17,6 @@ SingleCharMatch_T Single_Character_Matches[ NUM_SINGLE_CHAR_MATCHES ] = {
     { '-', SUB },
     { '*', MUL },
     { '/', DIV },
-    { '`', LIST },
     { '%', MACRO },
     { ':', SEP },
 };
@@ -100,6 +99,7 @@ Token DLLexer::next(void)
             SingleCharOp(ret);
         }
     }
+    cout << "token: " << ret.type() << endl;
     return ret;
 }
 
@@ -231,6 +231,7 @@ void DLLexer::SingleCharOp(Token& tok)
         {
             consume();
             tok = Token( Single_Character_Matches[i].type, line, column );
+            break;
         }
     }
 
index 7692b8db38a9e64769f5434782860bcb4b663dc0..223b62d24ae8e74bd2e6a68397c2f14d4048f799 100644 (file)
@@ -73,14 +73,14 @@ AST* DLParser::Expression(void)
         match(ASSIGN);
         ret = _new AST( ASSIGN, 2, id_node, Expression());
     }
-    else if( (lookaheadType(1) == MACRO) && (lookaheadType(2) == ID))
-    {
-        ret = MacroDefinition();
-    }
-    else if( isMacro( lookaheadToken(1) ) )
-    {
-        ret = MacroExpansion();
-    }
+    //else if( (lookaheadType(1) == MACRO) && (lookaheadType(2) == ID))
+    //{
+    //    ret = MacroDefinition();
+    //}
+    //else if( isMacro( lookaheadToken(1) ) )
+    //{
+    //    ret = MacroExpansion();
+    //}
     else
     {
         ret = LogicalExpr();
@@ -156,13 +156,13 @@ AST* DLParser::UnaryExpr(void)
 AST* DLParser::GroupExpr(void)
 {
     AST* ret = NULL;
-    if(lookaheadType(1) == LPAR)
-    {
-        match(LPAR);
-        ret = LogicalExpr();
-        match(RPAR);
-    }
-    else
+    //if(lookaheadType(1) == LPAR)
+    //{
+    //    match(LPAR);
+    //    ret = LogicalExpr();
+    //    match(RPAR);
+    //}
+    //else
     {
         ret = Literal();
         if( lookaheadType(1) == LPAR )
@@ -192,7 +192,7 @@ AST* DLParser::Literal(void)
             break;
 
         // Literal = ListLiteral
-        case LIST:
+        case LPAR:
             node = ListLiteral();
             break;
 
@@ -254,7 +254,6 @@ AST* DLParser::VectorLiteral(void)
 AST* DLParser::ListLiteral(void)
 {
     AST* ret = NULL;
-    match(LIST);
     match(LPAR);
     ret = ExpList(LIST, RPAR);
     match(RPAR);
index 5ad2487847a45861e09659c0d7ec341fd2ddcdbb..0ab48b25f53bb378e4f7a28d929634074fe1b2e8 100644 (file)
@@ -53,7 +53,7 @@ class DLParser : public BTParser
         //
         // VectorLiteral =  '[' ExpList ']'
         //
-        // ListLiteral = '`' '(' ExpList ')'
+        // ListLiteral = '(' ExpList ')'
         //
         // FuncLiteral = '{' ExpBlock '}'
         //             |  '{' '|' ExpList '|' ExpBlock '}'