parse_queue 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 680c9173be954876332f5a14f657c07d077efa62
4
- data.tar.gz: 57b611ff761a311887b602646f8027f7893ec5d7
3
+ metadata.gz: 36033d4abd23bd7092e28e8e1eb9fc405c87dbe1
4
+ data.tar.gz: c3d7c043db21c06ebd37e67ef0ab9e55fc7e59be
5
5
  SHA512:
6
- metadata.gz: b90020ad6dda6613549e9b4da6f45992e23a11475225fc8f2b9c93764143514677dbba428d6dc88b1b722dda90df96a161606a2ad1692e7155c8ab1201a0c344
7
- data.tar.gz: 8add940d513b2ba9883dc1c266d24511011f04b1205269f685133a0f68323f6fb8f4c833fba2427018dee0a0e13b4edd508b24a685110df58e90a84c6da94d0f
6
+ metadata.gz: 1fb132c9c248243091584674374a918723cd58e560202badf1675416f3d18bbda8ff4847628e8705522770bc74e827e6b6a6ca6808d098ef10619e36e63b1165
7
+ data.tar.gz: e1a412e86eb9bac422b7c387edd271d7fd4138ca237fb8a5ef2d4d1530a3823a04f87e7347bb4e6b2e17fc9389f1f15dc89294a71e62d1161df727976831759f
data/README.md CHANGED
@@ -7,6 +7,12 @@ simple queue, it supports backing up or falling back to earlier states allowing
7
7
  the parser to try other paths in the syntax tree when one path runs into a
8
8
  dead end.
9
9
 
10
+ The parse queue was created to simplify the design of both the lexical analyzer
11
+ and the parser. Parsers often have a built-in limited "look-ahead" of tokens.
12
+ This can be seen in parser names like LL(0), LL(1), LR(1), LALR(n), etc. The
13
+ parse queue provides for a flexible look-ahead removing this burden from other
14
+ compiler components.
15
+
10
16
  ## Installation
11
17
 
12
18
  Add this line to your application's Gemfile:
@@ -60,6 +66,12 @@ Getting an item from the queue is done with the get method. For example:
60
66
  This method returns the next unread item from the queue. Note that if no items
61
67
  are available, the exception **ParseQueueNoFwd** is raised.
62
68
 
69
+ Note: The get! method is a get without backtracking. In effect it is a get
70
+ followed by a shift (see Shifting below).
71
+
72
+ ```ruby
73
+ item = pq.get!
74
+ ```
63
75
 
64
76
  #### Backtracking:
65
77
 
data/lib/parse_queue.rb CHANGED
@@ -39,6 +39,13 @@ class ParseQueue
39
39
  result
40
40
  end
41
41
 
42
+ # Get an item and shift the buffer.
43
+ def get!
44
+ result = get
45
+ shift
46
+ result
47
+ end
48
+
42
49
  # Fetch all possible items.
43
50
  def fetch_all
44
51
  loop do
@@ -1,3 +1,3 @@
1
1
  class ParseQueue
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parse_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - PeterCamilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-24 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler