Gilad Bracha  committed c190d2a

More baby steps toward extended mixin support. Added InternalParser class in NewspeakParsing, useful for compiler internals and possibly for IDE to support global access during debugging.

  • Participants
  • Parent commits 22121b3
  • Branches default

Comments (0)

Files changed (2)

File NewspeakASTs.ns3

 	superclassCall: scc 					                         	
 	superConstructorCall: sk = AST (
 (* A class prefix defines everything about a class except for its mixin. 
-It is intended to serve as a common component between class declarations and mixin applications.
+It is intended to serve as a common component between ordinary class declarations and mixin applications.
+For Squeak compatibility, we maintain a category as well (ugh).
 name <Symbol> = n.
 constructor <MessagePatternAST> = k.
 superclassName <Symbol> = sn.
 superclassCall <NormalSendAST> = scc.
 superConstructorCall <MessageAST> = sk.
+category <CategoryAST>
 ('as yet unclassified'
 apply: visitor = (

File NewspeakParsing.ns3

 	protected VariablePatternAST = asts VariablePatternAST.
+class InternalParser = Parser (
+(* A parser able to handle identifiers involving the backquote character, `. 
+Such identifiers are illegal in regular Newspeak code, and are used as synthetic names in generated code, precisely because they cannot conflict with user code.
+Synthetic code that references such identifiers cannot be processed by the usual parser pipeline, and has often been manufactured by tedious and error prone manual AST construction.
+The intent is that instead, such code could be written as source code and parsedusing this parser, producing a valid AST that the rest of the compiler can use.
+  backTick = char: $`.
+  identifier = tokenFor:( 
+		(letter | _ | backTick),  ((letter | digit | _ | backTick)) star
+                 wrapper:[:fst   :snd  | fst asString, (String withAll: snd)]
+	).
+() : ()
 class Parser = TypedNS2Grammar (
 (* Parser for Newsqueak2. Produces a Newsqueak AST. This tree represents syntax only. No attribution information such as scopes/symbol tables, types etc. is present in the tree. The tree  only gives its structure and the source code positions of the nodes.