[svn] r7697: nemerle/trunk/ncc/parsing/MainParser.n
Luntain
svnadmin at nemerle.org
Mon Jun 4 12:43:46 CEST 2007
Log:
add two facility public static parse methods to MainParser, one to parse an expression given the first token of it, and one to parse function parameters given a round group; both methods take GlobalEnv as parameters and create their own instances of MainParser to parse the given tokens
Author: Luntain
Date: Mon Jun 4 12:43:45 2007
New Revision: 7697
Modified:
nemerle/trunk/ncc/parsing/MainParser.n
Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n (original)
+++ nemerle/trunk/ncc/parsing/MainParser.n Mon Jun 4 12:43:45 2007
@@ -159,7 +159,7 @@
}
}
- /// Parse function boby expression given lexer producing its content
+ /// Parse function body expression given lexer producing its content
/// and context in which this expression is situated.
public static ParseExpr (
[NotNull] env : GlobalEnv,
@@ -172,6 +172,16 @@
ParseFunctionBody (env, funHeader, tokens);
}
+ public static ParseExpr (
+ [NotNull] env : GlobalEnv,
+ [NotNull] token : Token
+ ) : PExpr
+ {
+ def parser = MainParser(env);
+ parser.push_stream(token);
+ parser.parse_expr(TokenStoppers.All)
+ }
+
public static ParseFunctionBody (
[NotNull] env : GlobalEnv,
[NotNull] funHeader : Fun_header,
@@ -189,6 +199,16 @@
parser.ParseBlock (tokens2, funHeader.parms);
}
+ public static ParseFunParms(
+ [NotNull] env: GlobalEnv,
+ [NotNull] round_group: Token.RoundGroup
+ ): list[Fun_parm]
+ {
+ def parser = MainParser(env);
+ parser.push_stream(round_group);
+ parser.parse_parameters()
+ }
+
/** Parse well formed source code of toplevel program, using the given instance
of [LexerBase] for obtaining tokens.
*/
@@ -2349,7 +2369,6 @@
match (env.SyntaxKeywords.Find (k)) {
| Some (syntax_definition) when syntax_definition.Target %&& ((1 << 15) :> MacroTargets) =>
parse_syntax_definition (syntax_definition, stop)
- | _ => fatal_error (tok, "unexpected keyword in expression context");
}
| _ => fatal_error (tok, "expecting expression");
More information about the svn
mailing list